| title | AlertDialog |
|---|---|
| description | A modal dialog that interrupts the user with important content and expects a response. Unlike Dialog, it does not close on outside click, requiring explicit user action. |
| source | packages/raystack/components/alert-dialog |
| tag | new |
import { playground, controlledDemo, menuDemo, discardDemo, nestedDemo } from "./demo.ts";
Import and assemble the component:
import { AlertDialog } from '@raystack/apsara'
<AlertDialog>
<AlertDialog.Trigger />
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title />
</AlertDialog.Header>
<AlertDialog.Body>
<AlertDialog.Description />
</AlertDialog.Body>
<AlertDialog.Footer>
<AlertDialog.Close />
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog>Groups all parts of the alert dialog.
Renders the alert dialog panel overlay.
Renders the alert dialog header section.
Renders the alert dialog title text.
Renders the main content area of the alert dialog.
Renders supplementary text within the alert dialog body.
Renders the element that opens the alert dialog.
Renders a button that closes the alert dialog.
Renders the alert dialog footer section.
Example of a controlled alert dialog with custom state management.
Open an alert dialog from a menu item. Since the trigger is outside the AlertDialog.Root, use the controlled open / onOpenChange props.
A common pattern for confirming destructive navigation. Both actions use AlertDialog.Close to dismiss the dialog.
You can nest alert dialogs for multi-step confirmation flows. When a nested alert dialog opens, the parent dialog automatically scales down and becomes slightly transparent.
- Alert dialog has
role="alertdialog"andaria-modal="true" - Does not close on outside click (backdrop), requiring explicit user action
- Uses
aria-labeloraria-labelledbyto identify the dialog - Uses
aria-describedbyto provide additional context - Focus is trapped within the alert dialog while open
- Respects motion preferences: alert dialog panel motion is enabled only when
prefers-reduced-motion: no-preference