UI.MD

Alert Dialog

A modal dialog that interrupts with important content and requires a response.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/alert-dialog.json

Usage

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

Examples

Default

API Reference

PropTypeDefaultDescription
openAlertDialogboolean-Controlled open state. Pair with onOpenChange.
defaultOpenAlertDialogbooleanfalseOpen state on first render when uncontrolled.
onOpenChangeAlertDialog(open: boolean) => void-Called when the open state changes.
renderAlertDialogTriggerReact.ReactElement-Replaces the default trigger button with your own element, e.g. render={<Button>Open</Button>}. Base UI merges props onto it.
variantAlertDialogAction"default" | "soft" | "outline" | "ghost" | "text" | "destructive" | "subtle" | "ghost-destructive" | "link""destructive"Button variant for the confirm button. <AlertDialogCancel /> is always a ghost button.