suiss/ui · Component
Alert Dialog
A modal dialog that interrupts the user to confirm an important action or acknowledge information.
Alert Dialog is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Alert Dialog wraps the alert dialog primitive of the chosen base. An AlertDialog root contains an AlertDialogTrigger and an AlertDialogContent. The content renders its own portal and scrim overlay, and typically holds an AlertDialogHeader (with optional AlertDialogMedia, plus AlertDialogTitle and AlertDialogDescription) followed by an AlertDialogFooter with AlertDialogCancel and AlertDialogAction buttons.
Use it when a decision must be made before continuing, such as signing out or deleting data. Unlike a regular dialog, it is not dismissed by clicking outside. For a choice of actions anchored to the bottom of the screen, use Alert Sheet.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
-
Add the pieces it builds on: Button,
use-scrollbar-gap. -
Copy the source into
components/ui/alert-dialog.tsx:
- Update the import paths to match your project.
Usage
AlertDialogContent already includes AlertDialogPortal and AlertDialogOverlay, so you rarely use those parts directly.
AlertDialogAction and AlertDialogCancel both close the dialog and render a Button; pass variant and size to style them. Cancel defaults to the secondary variant and Action to default. Use variant="destructive" on the action for irreversible operations.
The dialog is uncontrolled by default; use defaultOpen, or control it with open and onOpenChange.
Examples
Small
A narrower dialog using size="sm" with a destructive action.
With media
Adds an icon above the title with AlertDialogMedia.
API Reference
AlertDialog
The root that manages the open state.
Also accepts the props of the primitive part it wraps.
AlertDialogTrigger
The control that opens the dialog.
Also accepts the props of the primitive part it wraps.
AlertDialogPortal
Renders the dialog into a portal outside the DOM hierarchy.
Also accepts the props of the primitive part it wraps.
AlertDialogOverlay
The full-screen scrim behind the dialog.
Also accepts the props of the primitive part it wraps.
AlertDialogContent
The dialog surface, rendered with its own portal and overlay.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | Maximum width of the dialog. sm is narrower than default. |
Also accepts the props of the primitive part it wraps.
AlertDialogHeader
A centered layout wrapper for the media, title and description.
Also accepts the props of React.ComponentProps<"div">.
AlertDialogFooter
A two-column grid for the cancel and action buttons.
Also accepts the props of React.ComponentProps<"div">.
AlertDialogMedia
A circular container for an icon or image above the title.
Also accepts the props of React.ComponentProps<"div">.
AlertDialogTitle
The heading that names the dialog.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Title>.
AlertDialogDescription
Supporting text that describes the dialog.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Description>.
AlertDialogAction
A button that confirms and closes the dialog.
Also accepts the props of the primitive part it wraps, plus Button.
AlertDialogCancel
A button that dismisses the dialog without acting.
Also accepts the props of the primitive part it wraps, plus Button.
Accessibility
- The popup has the
alertdialogrole, named byAlertDialogTitleand described byAlertDialogDescription. - Opening moves focus into the dialog; closing returns focus to the trigger.
Escapecloses the dialog.- Clicking the overlay does not close it; a choice must be made with a footer button or
Escape.
Notes
- Styling hooks:
data-slotvalues fromalert-dialogthroughalert-dialog-cancel; the content also setsdata-size. - Surface tokens:
bg-popoverfor the dialog,bg-black/50for the overlay andbg-mutedfor media. - Enter and exit use fade and zoom animations keyed to
data-openanddata-closed.

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
The CLI also adds what it builds on: Button, Icon, Text. On React Native it also adds the animated view components/ui/animated-view.tsx.
Manual
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/use-render.tsx, and the animated viewcomponents/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/ui/alert-dialog.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/use-render.tsx, and the animated viewcomponents/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/ui/alert-dialog.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/use-render.tsx, and the animated viewcomponents/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/ui/alert-dialog.tsx:
- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
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

Small
The narrower sm content size.

With media
An icon badge above the title with AlertDialogMedia.

Destructive
A destructive action button for an irreversible confirmation.

API Reference
AlertDialog
The root that manages the open state.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Whether the dialog is open, for controlled use. |
defaultOpen | boolean | false | Whether the dialog starts open when uncontrolled. |
onOpenChange | (open: boolean, details) => void | - | Called when the dialog opens or closes. |
AlertDialogOverlay
Dimmed scrim behind the dialog.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Backdrop>.
AlertDialogContent
Centered card with scale and fade transitions.
| Prop | Type | Default | Description |
|---|---|---|---|
portalHost | string | - | Name of the portal host to render into. |
size | "default" | "sm" | "default" | default or sm maximum width. |
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Popup>.
AlertDialogHeader
Centered column for the title and description.
Also accepts the props of ViewProps.
AlertDialogFooter
Row of actions with equal-width buttons.
Also accepts the props of ViewProps.
AlertDialogMedia
Round badge for an icon above the title.
Also accepts the props of ViewProps.
AlertDialogTitle
Dialog heading.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Title>.
AlertDialogDescription
Supporting text below the title.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Description>.
AlertDialogAction
Button that confirms and closes the dialog.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Close>, React.ComponentProps<typeof Button>.
AlertDialogCancel
Secondary button that closes the dialog.
Also accepts the props of React.ComponentProps<typeof AlertDialogPrimitive.Close>, React.ComponentProps<typeof Button>.
Accessibility
- The popup has the
alertdialogrole, 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
headingrole, and the action buttons have thebuttonrole.
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-popover,bg-black/50,text-foregroundandtext-muted-foregroundtokens; light and dark follow the system appearance.




