Dialog
Root component for a modal dialog. Manages open/closed state and accessibility. Import from "@desk/ui/components/dialog".
Usage
@desk/ui/components/dialog
<Dialog>
<DialogTrigger asChild>
<Button emphasis="outline" icon={FolderPlus} tone="neutral">
Add to palette
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Add to palette</DialogTitle>
<DialogDescription>
File Terrazzo Bianco under a palette, or start a new one.
</DialogDescription>
</DialogHeader>
<Text variant="muted">Coastal Kitchen · 12 materials</Text>
<DialogFooter>
<DialogClose asChild>
<Button emphasis="outline" tone="neutral">
Cancel
</Button>
</DialogClose>
<DialogClose asChild>
<Button>Add to palette</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>Best practices
Use
Dialogfor a centered blocking modal (form, details, footer actions); a destructive confirm isAlertDialog, an anchored non-blocking panel isPopover.A panel that slides in from a screen edge is a
Sheet(orDrawerfor a drag-to-dismiss bottom sheet), not aDialog.Always render a
DialogTitle(wrap insr-onlyif visually hidden) so the modal is announced;DialogContentuses the 36px--radius-modalcorner.
Props
DialogContent
| Prop | Type | Default | Description |
|---|---|---|---|
| onClickOutside | (event: InteractOutsideEvent) => void | Callback when clicking outside the dialog (before | |
| overlayClassName | string | Extra classes for the overlay behind the dialog. | |
| showCloseButton | boolean | true | Show close button in the top-right corner. |
DialogFooter
| Prop | Type | Default | Description |
|---|---|---|---|
| justify | "end" | "between" | "end" | Button alignment within the footer. |
Also exports
- component
Dialog - const
dialogAnatomy - component
DialogClose - component
DialogDescription - component
DialogHeader - component
DialogOverlay - component
DialogPortal - component
DialogTitle - component
DialogTrigger
Anatomy
Dialog
dialogModal overlay for focused content
DialogTrigger
dialog-triggerButton to open the dialog
DialogContent
dialog-contentMain modal container
DialogHeader
dialog-headerHeader area
DialogTitle
dialog-titleModal heading
DialogDescription
dialog-descriptionModal description
DialogFooter
dialog-footerFooter with action buttons
Composition
Used by