Command palette

@yasinsensoy/native

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

import { Alert } from "@yasinsensoy/native";

<Alert tone="danger" title="Payment failed">
  Check your card details and try again.
</Alert>

Events

  1. Events appear here when you interact with the preview.

Import

import { Alert } from "@yasinsensoy/native";

Alert

component

In-page alert: info, success, warning or error. Screen readers read it immediately for danger/warning tones, in turn for the others.

Alert({ ref, tone: toneProp, variant: variantProp, effect, title, children, icon, action, onClose, style, }: AlertProps): JSX.Element

Examples

<Alert tone="danger" title="Payment failed">Check your card details.</Alert>
<Alert tone="warning" variant="soft" title="Trial ending" action={<Button size="sm">Upgrade</Button>} />

Alert style: outline bordered card, soft tinted background.

type AlertVariant = "outline" | "soft"

AlertProps

interface

Props of Alert.

NameTypeDefaultDescription
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?EffectPropEffect or effects ("beam", "shine"…). Defaults to appearance.defaults.alert.effect. See BuiltinEffect.
title?ReactNodeTitle.
children?ReactNodeDescription.
icon?IconPropIcon; defaults to the tone's icon, false for none.
action?ReactNodeAction on the right (below on narrow screens), e.g. a button.
onClose?() => voidWhen given, a close (×) button appears at the top right.
style?StyleProp<ViewStyle>Container style.