Alert Dialog
A modal confirmation that interrupts the user to demand a deliberate response.
Usage
AlertDialog is a compound component built on Base UI's Alert Dialog. It's a Dialog tuned for confirmations: it's always modal, it has no dismiss-by-clicking-outside and no close button, and it carries role="alertdialog" so assistive tech announces it as an interruption. The user has to choose one of the actions you provide. The root holds the open state; the parts compose the trigger and the portalled popup:
AlertDialogTrigger— the button that opens the dialog. Userenderto project it onto your ownButton(or any element).AlertDialogContent— the portalled, centered popup. It draws the card, the backdrop, and the focus trap, and accepts the shared modal props below.AlertDialogHeader— a layout wrapper grouping the title and description with the right spacing.AlertDialogTitle— an<h2>that labels the popup (aria-labelledby).AlertDialogDescription— a<p>that describes it (aria-describedby).AlertDialogBody— an optional region for longer content between the header and footer.AlertDialogFooter— a layout wrapper for the actions; stacks on small screens and right-aligns in a row fromsmup.AlertDialogClose— a button that closes the dialog; project it onto your ownButtonwithrender. Put your confirm and cancel actions here.
Reach for an AlertDialog only when continuing is consequential — deleting data, signing out, discarding edits. For a dismissible panel with arbitrary content, use a Dialog; for a transient, non-blocking message, use a Toast.
Examples
Destructive confirmation
The canonical use: a high-stakes action gated behind an explicit confirm. Give the confirm button the destructive Button variant so the danger reads at a glance, and keep the cancel action first so it's the easy, default-focused choice.
With media
Lead the header with media to anchor the message — an Avatar, a Thumbnail, or a plain icon. It sits above the title and inherits the dialog's spacing. This example also centers the header (text-center) and stretches the actions to equal widths (flex-1) for a more focused, app-like layout.
Asynchronous action (controlled)
When confirming kicks off async work, keep the dialog open until it settles — this is the everyday reason to control the open state. Drive open yourself and don't close from onOpenChange while the request is in flight: swap the confirm button to a loading state and disable cancel, then close once the promise resolves.
RTL
Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.
The header, body, and footer flip to read right-to-left, and the footer's actions mirror to the leading edge. The popup portals to <body>, so it follows the document direction — when you scope RTL to a subtree of an LTR page, set dir="rtl" on AlertDialogContent so the popup mirrors too. For setup details and caveats, see the RTL guide.
API reference
AlertDialog wraps Base UI's Alert Dialog. Each part forwards every remaining prop to the matching Base UI primitive, so anything it accepts works here — the tables below list the Appica additions and the most common props. See the Base UI docs for the complete API.
AlertDialog
The root. Holds the open state; renders no DOM of its own. Always modal, and not dismissible by an outside click — the user must pick an action.
AlertDialogTrigger
The button that opens the dialog. Forwards Base UI's AlertDialog.Trigger; use render to project it onto your own element.
AlertDialogContent
The portalled, centered popup. Draws the card, the backdrop, and the focus trap, and maps the underlying Base UI Portal / Backdrop / Viewport so you don't have to reach into them. Shared with Dialog and Drawer through the modal props.
AlertDialogHeader
A layout wrapper that groups the title and description with consistent padding and spacing.
AlertDialogTitle
An <h2> that labels the popup. Rendering one sets the popup's aria-labelledby.
AlertDialogDescription
A <p> that describes the popup. Rendering one sets the popup's aria-describedby.
AlertDialogBody
An optional region between the header and footer, for confirmations that carry more than a sentence (a changelog, a list of affected items). It doesn't scroll on its own — for content taller than the viewport, wrap it in a ScrollArea between the pinned header and footer.
AlertDialogFooter
A layout wrapper for the actions. Stacks them vertically on small screens (confirm on top) and lays them out in a right-aligned row from sm up.
AlertDialogClose
A button that closes the dialog. Forwards Base UI's AlertDialog.Close; project it onto your own element with render. Use it for both the confirm and the cancel action.
Accessibility
- The popup has
role="alertdialog", witharia-labelledbyandaria-describedbywired automatically fromAlertDialogTitleandAlertDialogDescription— always render both. - Opening traps focus inside the popup and blocks scroll/interaction with the rest of the page; Escape closes it and focus returns to the trigger.
- Unlike a
Dialog, clicking the backdrop does not dismiss it and there's no built-in close button — the user must pick one of your actions, which is the point of an alert dialog. - Focus lands on the first action by default; point it somewhere safer with
initialFocus(e.g. the cancel button) for destructive confirmations. - Popup enter/exit transitions are skipped when the user prefers reduced motion.