AlertDialog
4 partsA modal dialog that interrupts the user with important content and expects a
deliberate response. Built on top of Dialog, but always modal and rendered
with role="alertdialog" — focus moves to the Cancel button on open and
outside clicks are ignored, so the user must explicitly confirm or cancel.
Use it for destructive or irreversible actions (deleting data, discarding
changes); for non-blocking content prefer Dialog instead. Manages open state
and provides context to all parts. Bind v-model:open to control it.
Demo
Anatomy
Import the parts and compose them. Each part forwards attributes to its underlying element.
import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogRoot,
} from '@robonen/primitives/overlays/alert-dialog';
<AlertDialogRoot>
<AlertDialogAction />
<AlertDialogCancel />
<AlertDialogContent />
</AlertDialogRoot>API Reference
AlertDialogAction
ActionThe button that confirms the alert and closes the dialog. Use it for the action being warned about (e.g. "Delete"); wire your own handler to perform the work, the part only handles closing.
No props or events — renders its element and forwards attributes.
AlertDialogCancel
CancelThe button that dismisses the alert without acting and closes the dialog. Receives focus automatically when the alert opens, making it the safe default choice; always include one so the user has a non-destructive way out.
No props or events — renders its element and forwards attributes.
AlertDialogContent
ContentThe container for the alert's content, rendered into the portal with `role="alertdialog"`. Hosts the Title, Description, Cancel, and Action parts, moves focus to Cancel on open, and disables dismissal via outside clicks or loss of focus so the alert can only be resolved by an explicit choice.
No props or events — renders its element and forwards attributes.
AlertDialogRoot
RootA modal dialog that interrupts the user with important content and expects a deliberate response. Built on top of Dialog, but always modal and rendered with `role="alertdialog"` — focus moves to the Cancel button on open and outside clicks are ignored, so the user must explicitly confirm or cancel. Use it for destructive or irreversible actions (deleting data, discarding changes); for non-blocking content prefer Dialog instead. Manages open state and provides context to all parts. Bind `v-model:open` to control it.
| Prop | Type | Description |
|---|---|---|
open? | boolean | undefined | Two-way bound value (v-model:open). |
| Event | Payload |
|---|---|
update:open | [value: boolean | undefined] |