Dialog
A modal dialog that interrupts the user with important content and expects a response.
Installation
bash
npx shadcn@latest add dialogImport
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose,} from "@/components/ui/dialog"Basic Dialog
Destructive action
Props
PROPTYPEDEFAULTDESCRIPTION
openboolean—Controlled open stateonOpenChange(open: boolean) => void—Called when open state changesdefaultOpenbooleanfalseInitial open state (uncontrolled)modalbooleantrueWhether to render as a modalonInteractOutside(e: Event) => void—Called on outside click; call e.preventDefault() to block closeonEscapeKeyDown(e: KeyboardEvent) => void—Called on Escape keyAccessibility
- Focus is trapped inside the dialog when open
DialogTitleandDialogDescriptionare automatically wired toaria-labelledbyandaria-describedby- Pressing Escape closes the dialog by default
- Background content gets
aria-hiddenwhen dialog is open