AlertDialog

4 parts

A 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

Loading demo…

Anatomy

Import the parts and compose them. Each part forwards attributes to its underlying element.

vue
import {
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogRoot,
} from '@robonen/primitives/overlays/alert-dialog';

<AlertDialogRoot>
  <AlertDialogAction />
  <AlertDialogCancel />
  <AlertDialogContent />
</AlertDialogRoot>

API Reference

AlertDialogAction

Action

The 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

Cancel

The 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

Content

The 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

Root

A 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.

PropTypeDescription
open?boolean | undefinedTwo-way bound value (v-model:open).
Emits
EventPayload
update:open[value: boolean | undefined]