suiss/uim · React Native Component

Alert Dialog

A modal dialog that interrupts the user with an important message and asks for a response.

Alert Dialog is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Alert Dialog (open by default) on iOS in light mode

AlertDialog is a modal that cannot be dismissed by tapping the scrim. AlertDialogContent renders through a portal (inside a full-window overlay on iOS) with a dimmed scrim and a centered card that scales and fades in.

Use it for confirmations that need an explicit choice, such as deleting data. For less critical content that can be dismissed freely, use Dialog; for a list of choices anchored to the bottom of the screen, use Alert Sheet.

Installation

$ pnpm dlx @esuiss/uim@latest add alert-dialog

The CLI also adds what it builds on: Button, Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn react-native-reanimated react-native-screens react-native-worklets
  1. Add the pieces it builds on: Button, Icon, Text, and the primitives components/primitives/alert-dialog.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/alert-dialog.tsx:

uniwind/components/ui/alert-dialog.tsx
import { cn } from "cn"
import * as React from "react"
import { Platform, View, type ViewProps } from "react-native"
import {
  FadeIn,
  FadeOut,
  Keyframe,
  ReduceMotion,
} from "react-native-reanimated"
import { FullWindowOverlay as RNFullWindowOverlay } from "react-native-screens"
import * as AlertDialogPrimitive from "@/components/primitives/alert-dialog"
import { resolveClassName } from "@/components/primitives/use-render"
import { AnimatedView } from "@/components/ui/animated-view"
import { Button } from "@/components/ui/button"
import { IconClassContext } from "@/components/ui/icon"
import { TextClassContext } from "@/components/ui/text"
  1. Update the import paths to match your project.

Usage

import { AlertDialogOverlay, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogMedia, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from "@/components/ui/alert-dialog"
<View className="items-start">
  <AlertDialog defaultOpen>
    <AlertDialogTrigger render={<Button variant="outline" />}>
      <Text>Show dialog</Text>
    </AlertDialogTrigger>
    <AlertDialogBody />
  </AlertDialog>
</View>

Compose AlertDialogTrigger, then AlertDialogContent with an AlertDialogHeader (AlertDialogTitle, AlertDialogDescription) and an AlertDialogFooter holding AlertDialogCancel and AlertDialogAction. Both footer buttons close the dialog and stretch to equal widths inside the footer.

AlertDialogAction and AlertDialogCancel accept Button's variant and size; use variant="destructive" for destructive confirmations. Add AlertDialogMedia above the title for an icon badge.

Use open and onOpenChange for controlled state, or defaultOpen for uncontrolled. Pass portalHost to render into a named portal host.

Examples

Default

iOS
Alert Dialog on iOS in light mode

Small

The narrower sm content size.

iOS
Alert Dialog (small) on iOS in light mode

With media

An icon badge above the title with AlertDialogMedia.

iOS
Alert Dialog (with media) on iOS in light mode

Destructive

A destructive action button for an irreversible confirmation.

iOS
Alert Dialog (destructive) on iOS in light mode

API Reference

AlertDialogOverlay

Dimmed scrim behind the dialog.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Backdrop>

AlertDialogContent

Centered card with scale and fade transitions.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Popup>
PropType
About
Name of the portal host to render into.
Type
string
Default
—
About
default or sm maximum width.
Type
"default""sm"
Default
"default"

AlertDialogHeader

Centered column for the title and description.

ExtendsViewProps

AlertDialogFooter

Row of actions with equal-width buttons.

ExtendsViewProps

AlertDialogMedia

Round badge for an icon above the title.

ExtendsViewProps

AlertDialogTitle

Dialog heading.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Title>

AlertDialogDescription

Supporting text below the title.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Description>

AlertDialogAction

Button that confirms and closes the dialog.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Close>React.ComponentProps<typeof Button>

AlertDialogCancel

Secondary button that closes the dialog.

ExtendsReact.ComponentProps<typeof AlertDialogPrimitive.Close>React.ComponentProps<typeof Button>

Accessibility

  • The popup has the alertdialog role, is labelled by the title and is marked as modal for VoiceOver.
  • Focus moves to the title when the dialog opens.
  • Tapping the scrim does not close it; the Android back button and the VoiceOver escape gesture do.
  • The title has the heading role, and the action buttons have the button role.

Notes

  • On iOS the content is wrapped in a full-window overlay so it appears above native navigation.
  • Enter and exit animations respect the system Reduce Motion setting.
  • Uses bg-surface-raised, bg-scrim and label tokens; light and dark follow the system appearance.