Docs
alert dialog
alert dialog
A modal dialog temporarily interrupts the user's workflow with important content, requiring immediate attention and a response before allowing further interaction.
Installation
npx duck-ui@latest add alert-dialog
npx duck-ui@latest add alert-dialog
Usage
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import { Button } from '@/components/ui/button';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import { Button } from '@/components/ui/button';
<AlertDialog>
<AlertDialogTrigger>Open</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>
<AlertDialog>
<AlertDialogTrigger>Open</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>
API Reference
AlertDialogProps
defaultOpen
(boolean
, optional): Determines if the dialog should be open by default.open
(boolean
, optional): Controls the visibility of the dialog.onOpenChange
((open: boolean) => void
, optional): Callback function triggered when the dialog opens or closes.
AlertDialogTrigger
asChild
(boolean
): Iftrue
, the trigger will be rendered as a child element.
AlertDialogContent
-
asChild
(boolean
): Iftrue
, the content will be rendered as a child element. -
forceMount
(boolean
): Iftrue
, forces the content to mount. -
onOpenAutoFocus
((event: Event) => void
): Callback for managing focus when the dialog opens. -
onCloseAutoFocus
((event: Event) => void
): Callback for managing focus when the dialog closes. -
onEscapeKeyDown
((event: KeyboardEvent) => void
): Callback for handling the Escape key press.