# Alert dialog

> Confirms a destructive or irreversible action; clicking outside does not dismiss it.

Category: Overlays · Atomic level: organism · Built on Base UI AlertDialog
Page: https://ui.dtheo.dev/docs/components/alert-dialog

## Install

```bash
npx dtheo@latest add alert-dialog
# or, with the shadcn CLI
npx shadcn@latest add https://ui.dtheo.dev/r/alert-dialog.json
```

Dependencies: @base-ui/react, clsx, tailwind-merge. Registry dependencies: utils, dialog, button.

## Exports

`AlertDialog`, `AlertDialogTrigger`, `AlertDialogContent`, `AlertDialogTitle`, `AlertDialogDescription`, `AlertDialogFooter`, `AlertDialogClose`

## Use it for

- Deleting data, discarding unsaved work, irreversible operations

## Reach for something else

- Routine confirmations: offer undo instead

## Keyboard

| Keys | Action |
| --- | --- |
| Escape | Cancels |

## Accessibility

- Name the consequence in the title ("Delete 3 runs?") and the action in the button ("Delete runs").

## Examples

### alert-dialog

```tsx
import { Trash2Icon } from 'lucide-react';
import {
  AlertDialog,
  AlertDialogClose,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogTitle,
  AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import { Button } from '@/components/ui/button';
import { useToast } from '@/components/ui/toast';

export default function AlertDialogExample() {
  const toast = useToast();
  return (
    <AlertDialog>
      <AlertDialogTrigger render={<Button variant="destructive" />}>
        <Trash2Icon aria-hidden="true" />
        Delete 3 runs
      </AlertDialogTrigger>
      <AlertDialogContent>
        <div className="flex flex-col gap-1.5">
          <AlertDialogTitle>Delete 3 runs?</AlertDialogTitle>
          <AlertDialogDescription>
            R-0409, R-0410 and R-0411 and their traces (1.2 GB) are removed for everyone on the team. This
            cannot be undone.
          </AlertDialogDescription>
        </div>
        <AlertDialogFooter>
          <AlertDialogClose render={<Button variant="ghost" />}>Keep runs</AlertDialogClose>
          <AlertDialogClose
            render={<Button variant="destructive" />}
            onClick={() =>
              toast.add({
                title: '3 runs deleted',
                description: 'R-0409 to R-0411 and their traces were removed.',
              })
            }
          >
            Delete runs
          </AlertDialogClose>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
```

## Used in

- Run review (page): https://ui.dtheo.dev/examples/run-review
