Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
Installation
pnpm dlx shadcn@latest add @lumi-ui/alert-dialog
Basic Usage
Import the AlertDialog
, AlertDialogTrigger
, AlertDialogPopup
, AlertDialogHeader
, AlertDialogTitle
, AlertDialogDescription
, AlertDialogBody
, and AlertDialogFooter
components. Compose them to create a simple alert dialog.
Recipes
Customizing the Dialog
You can customize the dialog by passing props to the AlertDialogPopup
component. For example, you can change the variant
to destructive
to indicate a destructive action.
Anatomy
<AlertDialog>
<AlertDialogTrigger />
<AlertDialogPopup>
<AlertDialogHeader>
<AlertDialogTitle />
<AlertDialogDescription />
</AlertDialogHeader>
<AlertDialogBody />
<AlertDialogFooter />
</AlertDialogPopup>
</AlertDialog>
Migration from shadcn/ui
The component has been renamed from AlertDialog
to AlertDialog
for consistency. The names for content panels
and labels
have also been updated.
Key Differences & New Features
AlertDialog
component introduces several enhancements for better positioning and styling, which are exposed as props on the AlertDialogPopup
component.
Migration Example
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
function Demo() {
return (
<AlertDialog>
<AlertDialogTrigger>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>
);
}