Skip to content
Native Animation
Base Alert animation previewBase Alert animation preview

This preview uses fictional demo content. See the props below for the customization options available in this component.

npx nativeanimation add base-alert

Base Alert

React Native Alert Component

An inline alert with an animated entrance and collapsing dismissal, configurable tone, icon, title, description, action, and theme.

Native Animation Base · Free · MIT

Add to your project

Copy the component and its assets into your app with the Native Animation CLI, or paste the agent prompt into Claude Code, Codex or Cursor once the MCP server is connected.

About this component

An inline alert with an animated entrance and collapsing dismissal, configurable tone, icon, title, description, action, and theme.

How it works

  1. A card-colored surface uses a 1 px border, large radius, 16 pt horizontal and 12 pt vertical padding.
  2. Content enters from −6 pt with a 300 ms fade. Destructive descriptions use 90% of the destructive text color.
  3. Dismissal fades for 200 ms, then collapses the measured height over 280 ms before calling onDismiss.
  4. Set visible to hide or show the alert. After an internal dismissal, toggle it off and on or remount to show it again. Keep it mounted until the callback finishes.

Install

npx nativeanimation add base-alert

The CLI also copies the family modules listed in registryDependencies. Dependencies, if you copy by hand:

npx expo install lucide-react-native react-native-svg react-native-gesture-handler react-native-reanimated react-native-worklets

Usage

import { AlertCircle } from 'lucide-react-native';
import { BaseAlert } from './base-alert';
import { BaseButton } from './base-button';

<BaseAlert
  visible={visible}
  variant="destructive"
  icon={<AlertCircle size={16} color={theme.colors.destructive} />}
  title="Could not sync"
  description="Your changes are safe on this device."
  action={<BaseButton onPress={retry}>Try again</BaseButton>}
  onDismiss={() => setVisible(false)}
/>

Wrap your app in BaseThemeProvider (from base-theme) to choose light/dark and an accent; without it, pieces use the light neutral theme. Every piece also takes a theme prop that wins over the provider.

Props

PropTypeDefaultDescription
variant'default' | 'destructive'defaultText tone; supply an icon in the matching theme color.
iconReactNode—Leading 16 pt icon; offset 2 pt downward.
titlestring—Required single-line title.
descriptionstring—Supporting message.
actionReactNode—Optional action below the message.
onDismiss() => void—Enables the close button; called after a completed exit, including visible=false.
visiblebooleantrueControls visibility with an animated exit.
dismissLabelstringDismiss alertAccessible close button label.
themeBaseThemeproviderOverrides the theme from BaseThemeProvider.
styleStyleProp<ViewStyle>—Container style.
testIDstring—Stable identifier on the root view.

Compatibility

Expo SDK 58 · React Native 0.88 · Reanimated 4.7 · react-native-worklets 0.13. Runs on iOS, Android and web, in Expo Go and in development builds. Part of Native Animation Base, a free family that shares one theme: install base-theme once (the CLI does it for you) and every Base piece picks it up. Free forever. MIT.

Accessibility

Destructive alerts use the alert role; updates use a polite live region. The close button supports touch, screen reader activation, and Enter/Space. Its 44 pt target has Android hit slop to reach 48 dp. With Reduce Motion on, all entrance and dismissal changes are immediate. Caller-supplied icons should use 16 pt and the matching foreground or destructive theme color.

Source code

Loading public source…