The Alert Dialog component displays a modal dialog that interrupts the user to confirm a critical action. Unlike regular dialogs, alert dialogs cannot be dismissed by clicking the overlay — users must explicitly choose an action. Built on Radix UI Alert Dialog.
Import
import {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
} from'@nim-ui/components';
Basic Usage
Basic Alert Dialog
View Code
<AlertDialog>
<AlertDialogTriggerasChild>
<Buttonvariant="outline">Delete Item</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete the item.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancelasChild>
<Buttonvariant="outline">Cancel</Button>
</AlertDialogCancel>
<AlertDialogActionasChild>
<Button>Continue</Button>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
Destructive Variant
Use variant="destructive" for dangerous actions like account deletion. This adds a red accent border to visually signal danger.