# Alert Dialog

> Confirmation dialog with cancel and action buttons.

Registry name: `alert-dialog`. HTML docs: https://ui.anuragroy.dev/component/alert-dialog.

## Install

```bash
npx shadcn@latest add https://ui.anuragroy.dev/r/alert-dialog.json
```

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/alert-dialog.json`.

Registry JSON: https://ui.anuragroy.dev/r/alert-dialog.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/alert-dialog.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger
} from "@/components/ui/alert-dialog"
```

## Usage

```tsx
import { Button } from "@/components/ui/button"
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"

export function Example() {
  return (
    <AlertDialog>
      <AlertDialogTrigger render={<Button variant="destructive" />}>
        Delete item
      </AlertDialogTrigger>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>Are you sure?</AlertDialogTitle>
          <AlertDialogDescription>
            This action cannot be undone.
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel>Cancel</AlertDialogCancel>
          <AlertDialogAction>Continue</AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  )
}
```

## API

### AlertDialog

Base UI AlertDialog root.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | boolean | — |  |
| `onOpenChange` | (open: boolean) => void | — |  |

## Notes

- `AlertDialogTitle` is required for accessibility.

## See also

- [HTML page](https://ui.anuragroy.dev/component/alert-dialog): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/alert-dialog.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
