# Alert — React Native component for Expo

> An inline banner whose icon draws itself inside a halo, with an optional draining timer.

Inline banner with a living icon that draws itself inside a halo, a soft light-leak glow of its tone, and primary + secondary actions. Optional auto-dismiss shows the time left as a hairline draining along the bottom (pauses while touched), and on dismiss it collapses smoothly so content below glides up.

- Docs: https://expokit.in/docs/components/alert
- Tier: Free
- Also called: alert banner, callout, inline notification
- Category: Feedback
- Platforms: iOS, Android, web
- Expo Go: yes, no development build needed
- npm dependencies: react-native-svg, expo-haptics
- Uses ExpoKit items: kit
- Variants: Soft, Appearances, With Actions, Auto Dismiss, Dismissible, Compact

## Installation

Run once per project: `npx @expokit/cli@latest init` (shared theme + KitProvider). Then:

```bash
npx @expokit/cli@latest add alert
```

The CLI copies the source into your project (you own the code) and installs react-native-svg, expo-haptics.

Import: `import { Alert } from "@/components/ui/alert";`

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"info" \| "success" \| "warning" \| "danger"` | `"info"` | Tone and living icon. |
| `appearance` | `"soft" \| "outline" \| "solid" \| "accent-bar"` | `"soft"` | Card with a tone glow behind the icon, transparent with a hairline tone border, or filled with the solid tone. "accent-bar" is deprecated and renders as "soft". |
| `title` | `string` | — | First line. Without a title (and without actions) the alert uses the compact single-line layout. |
| `description` | `ReactNode` | — | Supporting text. |
| `action` | `{ label, onPress } \| ReactNode` | — | One action: a tone pill under the text, or an inline pill on the right in the compact layout. |
| `actions` | `{ primary: { label, onPress }, secondary?: { label, onPress } }` | — | Pill pair on the bottom row; primary is filled with the tone. |
| `icon` | `ReactNode \| false` | `living tone icon` | Custom icon (shown in the halo) or none. |
| `dismissible` | `boolean` | `false` | Show a 28pt close button (44pt hit area) that collapses the alert. |
| `duration` | `number (ms)` | — | Auto-dismiss. A hairline drains along the bottom edge; pauses while pressed or hovered. |
| `visible` | `boolean` | — | Controlled visibility (animated). |
| `onDismiss` | `() => void` | — | Called when closed by the button or when `duration` runs out. |
| `haptics` | `boolean` | `false` | Notification haptic (success / warning / error) when the alert appears. |
| `color` | `string` | `tone colour` | Override the tone colour. |
| `dismissLabel` | `string` | `labels.dismiss` | Screen-reader name of the dismiss button. Set it app-wide with KitProvider's labels. |
| `style` | `StyleProp<ViewStyle>` | — | Style for the outer animated wrapper (its height collapses on dismiss). |
| `className` | `string` | — | Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. |

## Behaviour & accessibility

- **Motion**: On appear the icon outline draws, the glyph springs in and the halo ripples once. Dismissing collapses the height so content below glides up.
- **Touch**: With duration set, a hairline drains along the bottom to show the time left. Pressing the alert pauses it.
- **Reduced motion**: The icon draw, glyph pop and halo ripple jump straight to their finished state.
- **Haptics**: Success, warning and danger alerts play the matching notification haptic when they appear; info stays silent.
- **Screen readers**: The card has the alert role in a polite live region. The close button is labelled Dismiss and actions are buttons named by their label.
- **Web**: Hovering also pauses the auto-dismiss timer.

## FAQ

### How do I make an alert banner in React Native?

Use ExpoKit's Alert: run npx @expokit/cli@latest add alert in your Expo or React Native project and it copies a ready-made alert banner into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.

### Does Alert work in Expo Go?

Yes. Alert runs in Expo Go on iOS and Android with no development build — its packages (react-native-svg, expo-haptics) are all included in Expo Go.

### How do I add Alert to my Expo app?

Run npx @expokit/cli@latest add alert in your project. The CLI copies the component's source into your app and installs react-native-svg, expo-haptics, so the code is yours to change.

### Is Alert free?

Yes. Alert is free: its full source is on this page and the CLI installs it without an account.

### Can I change how Alert looks?

Yes. It takes its colours, radius and light / dark mode from useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.

## More

- Live preview, variants and code: https://expokit.in/docs/components/alert
- Every ExpoKit component, screen, template and chart: https://expokit.in/llms.txt
- Install commands and props for every free component: https://expokit.in/llms-full.txt
- Pricing: https://expokit.in/pricing
