React Native · Components
Alert
In-page alert: info, success, warning or error.
3 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
Alert
componentIn-page alert: info, success, warning or error. Screen readers read it immediately for danger/warning tones, in turn for the others.
Examples
AlertVariant
typeAlert style: outline bordered card, soft tinted background.
AlertProps
interfaceProps of Alert.
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<ViewRef> | Ref of the underlying native element. | |
tone? | Tone | "neutral"` (or `appearance.defaults.alert.tone`) | Color and default icon. |
variant? | AlertVariant | (string & {}) | "outline" | Variant: one of the built-in variants or a name added via appearance.variants.alert. |
effect? | EffectProp | Effect or effects ("beam", "shine"…). Defaults to appearance.defaults.alert.effect. See BuiltinEffect. | |
title? | ReactNode | Title. | |
children? | ReactNode | Description. | |
icon? | IconProp | Icon; defaults to the tone's icon, false for none. | |
action? | ReactNode | Action on the right (below on narrow screens), e.g. a button. | |
onClose? | () => void | When given, a close (×) button appears at the top right. | |
style? | StyleProp<ViewStyle> | Container style. |