Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Demo

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

ts
import {
  AlertDialog,
  AlertDialogTrigger,
  AlertDialogPortal,
  AlertDialogOverlay,
  AlertDialogContent,
  AlertDialogHeader,
  AlertDialogFooter,
  AlertDialogMedia,
  AlertDialogTitle,
  AlertDialogDescription,
  AlertDialogAction,
  AlertDialogCancel,
} from "@/components/ui/alert-dialog";

Basic

Dark previewReplay previewOpen in new tab

Small

Set size="sm" on AlertDialogContent for a compact dialog.

Dark previewReplay previewOpen in new tab

Media

AlertDialogMedia renders an icon or image alongside the header.

Dark previewReplay previewOpen in new tab

Small with Media

Dark previewReplay previewOpen in new tab

Destructive

Pass variant to AlertDialogAction and AlertDialogCancel for destructive confirmations.

Dark previewReplay previewOpen in new tab

API Reference

AlertDialogContent

PropTypeDefaultDescription
size"default" | "sm""default"Dialog size. sm centers content and stacks the footer in a 2-col grid.

AlertDialogAction / AlertDialogCancel

PropTypeDefaultDescription
variantButtonVariants["variant"]default / "outline"Button style, e.g. destructive.
sizeButtonVariants["size"]"default"Button size.

AlertDialogMedia

PropTypeDefaultDescription
classstring—Container for an icon or image in the header.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
EscCloses the dialog (returns focus to the trigger).
TabFocus is trapped inside the dialog while open.
  • Unlike Dialog, clicking outside does not close an alert dialog; the user must choose an action.