Dialog
Asks for a decision, or a few details, without leaving the page. It rises and settles on a spring over a softly blurred scrim, and closes quickly and quietly.
Install
npx shadcn@latest add @nelumbo/dialogBasic
A title that asks the question, a sentence of context, and the actions. Put the main action last; Escape or a click on the scrim cancels.
With an icon
A hero icon above the title centers the header. Use it for alerts and confirmations that deserve a beat of attention.
Form
For a few fields. The close button sits in the corner; focus starts on the first field.
Scrolling content
DialogBody scrolls between a fixed header and footer. Hairlines appear at its edges only while there is more to read.
Sizes
sm (400px) for confirmations, default (512px) for forms, lg (672px) for richer content. On small screens every size keeps a 16px margin.
Usage
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogIcon, DialogTitle, DialogDescription, DialogBody, DialogFooter, DialogClose } from "@/components/ui/dialog"<Dialog> <DialogTrigger asChild><Button>Delete</Button></DialogTrigger> <DialogContent size="sm" showCloseButton={false}> <DialogHeader> <DialogIcon name="delete" /> <DialogTitle>Delete 3 files?</DialogTitle> <DialogDescription>This can't be undone.</DialogDescription> </DialogHeader> <DialogFooter> <DialogClose asChild><Button variant="ghost">Cancel</Button></DialogClose> <Button variant="destructive">Delete</Button> </DialogFooter> </DialogContent></Dialog>Props
Dialog, DialogTrigger and DialogClose take Radix Dialog props (open, onOpenChange, modal…).
| Prop | Type | Default | Notes |
|---|---|---|---|
DialogContent size | "sm" | "default" | "lg" | "default" | 400, 512 or 672px wide |
DialogContent showCloseButton | boolean | true | Close button in the corner |
DialogIcon name | IconName | Hero icon; centers the header | |
DialogBody | Scrolling region with edge hairlines |