Dialog
A window overlaid on the page, holding focus until dismissed.
Installation
npx shadcn@latest add @blank/dialogUsage
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"<Dialog>
<DialogTrigger asChild>
<Button variant="outline">Open</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Changes are saved when you click Save.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<Button>Save</Button>
</DialogFooter>
</DialogContent>
</Dialog>Examples
Close button in the footer
showCloseButton moves the dismiss action from the corner into the footer. Use it for dialogs whose only action is closing.
Scrollable content
Give the content a max height and a three-row grid; the middle row scrolls while the header and footer stay in place.
API Reference
Dialog
Every Radix Dialog.Root prop: open, defaultOpen, onOpenChange, modal.
DialogContent
Every Radix Dialog.Content prop, plus:
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | true |
DialogFooter
Every div prop, plus:
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | false |