GitHub 560+

Alert Dialog

A modal dialog for important confirmations that expects a response.

Installation

npx shadcn@latest add @fulldev/alert-dialog

Usage

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
<AlertDialog>
  <AlertDialogTrigger variant="outline">Show Dialog</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
      <AlertDialogDescription>
        This action cannot be undone. This will permanently delete your account
        and remove your data from our servers.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Composition

Use the following composition to build an AlertDialog:

AlertDialog
├── AlertDialogTrigger
└── AlertDialogContent
    ├── AlertDialogHeader
    │   ├── AlertDialogMedia
    │   ├── AlertDialogTitle
    │   └── AlertDialogDescription
    └── AlertDialogFooter
        ├── AlertDialogCancel
        └── AlertDialogAction

Notes

  • Use AlertDialog for irreversible or high-risk actions, not routine inline confirmations.
  • Keep AlertDialogTitle and AlertDialogDescription inside AlertDialogContent so screen readers announce the dialog context clearly.
  • Pair the destructive path with AlertDialogAction and the safe path with AlertDialogCancel.
  • Use size="sm" on AlertDialogContent for compact confirmations and AlertDialogMedia when the dialog needs an icon or visual cue.

API Reference

See the GitHub source code for more information on props. See the data-slot docs for more information on interactivity.