Dialog
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
Installation#
pnpm dlx shadcn@latest add @davinciui/dialogUsage#
Composition: Dialog → DialogTrigger + DialogContent → DialogHeader → DialogTitle + DialogDescription + DialogFooter.
Close: Custom close replaces default via <DialogClose asChild> or hide via showCloseButton={false} on DialogContent.
Scrolling: Use DialogContent className="flex max-h-[80vh] flex-col" with scrollable inner div for sticky footer/content.
Composition#
Use the following composition to build a Dialog:
Dialog
├── DialogTrigger
└── DialogContent
├── DialogHeader
│ ├── DialogTitle
│ └── DialogDescription
├── DialogBody
└── DialogFooterAPI Reference#
| Prop | Type | Default |
|---|---|---|
DialogRoot. Controls open state. | Component | — |
DialogTriggerButton that opens the dialog. Supports asChild. | Component | — |
DialogContentCentered popup. Props: showCloseButton (default true), size (sm | md | lg | xl, default md). | Component | — |
DialogHeaderHeader wrapper for Title + Description. | Component | — |
DialogBodyScrollable body region with overlay scrollbar and scroll containment. | Component | — |
DialogTitleAccessible title. | Component | — |
DialogDescriptionAccessible description. | Component | — |
DialogFooterFooter for actions. Use with sticky layout. | Component | — |
DialogCloseClose button. Supports asChild. | Component | — |
showCloseButtonShow default X close button (DialogContent). | boolean | true |
classNameAdditional CSS classes. | string | — |
Accessibility#
Base UI traps focus, makes the background inert, closes on Escape, and returns focus to the trigger. The popup is role='dialog' with aria-labelledby and aria-describedby wired to DialogTitle and DialogDescription, so both parts should be present. The default close button has an aria-label.
Motion#
The popup rises 16px and scales from 0.98 over 220ms ease-out, exits in 120ms with accelerating easing, and the overlay fades over 200ms. motion-reduce:transition-none disables both, and no duration or easing props are exposed.
Customization#
Each dialog part renders a data-slot hook, so the overlay, positioner, and content can be themed independently. Use the size prop for the built-in content widths and className for one-off layout.
Styling slots
[data-slot="dialog"][data-slot="dialog-trigger"][data-slot="dialog-portal"][data-slot="dialog-overlay"][data-slot="dialog-positioner"][data-slot="dialog-content"][data-slot="dialog-close"][data-slot="dialog-close-button"][data-slot="dialog-header"][data-slot="dialog-body"][data-slot="dialog-footer"][data-slot="dialog-title"][data-slot="dialog-description"]View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

