docs/components/alert-dialog
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Dialog for displaying important content.
Alert Dialog is built on top of the Dialog component. Check it out for more examples.
PreviewCode
Open
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/alert-dialog
AlertDialog
├── AlertDialogTrigger
└── AlertDialogContent
├── AlertDialogHeader
│ ├── AlertDialogTitle
│ └── AlertDialogDescription
├── AlertDialogBody
├── AlertDialogFooter
│ ├── AlertDialogCancel
│ └── AlertDialogAction
└── AlertDialogClose
import {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogBody,
AlertDialogFooter,
AlertDialogAction,
AlertDialogCancel,
} from "@/components/ui/alert-dialog";
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Open</Button>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Allow accessory to connect?</AlertDialogTitle>
<AlertDialogDescription>
Do you want to allow the USB accessory to connect to this device?
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogBody />
<AlertDialogFooter>
<AlertDialogCancel>
Don't allow
</AlertDialogCancel>
<AlertDialogClose asChild>
<AlertDialogAction>Allow</AlertDialogAction>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
AlertDialogHeader supports two usage patterns:
Pass title and description props directly to AlertDialogHeader.
<AlertDialogHeader
title="Allow accessory to connect?"
description="Do you want to allow the USB accessory to connect to this device?"
>
<AlertDialogAction />
</AlertDialogHeader>
This approach does not require
AlertDialogTitleorAlertDialogDescriptioncomponents.
Use AlertDialogTitle and AlertDialogDescription as children for more control.
<AlertDialogHeader>
<AlertDialogTitle>Allow accessory to connect?</AlertDialogTitle>
<AlertDialogDescription>
Do you want to allow the USB accessory to connect to this device?
</AlertDialogDescription>
<AlertDialogAction />
</AlertDialogHeader>
PreviewCode
Open
Primary action.
| Prop | Type | Default |
|---|---|---|
variant | `"default" | "destructive"` |
className | string | - |
asChild | boolean | false |
Cancel action.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
For a complete list of props, see the Dialog API Reference.
[
Previous page
Action Bar ](/docs/components/action-bar)[
Next page
Alert ](/docs/components/alert)
On This Page
InstallationAnatomyUsageTitle & DescriptionUsing propsUsing componentsExamplesDestructiveAPI ReferenceAlertDialogActionAlertDialogCancel