Design system / Molecules
Molecule / Disclosure
Dialog
Dialog provides Radix-backed modal disclosure, focus handling and portaled content. The caller supplies a title, description and exit paths. Drafts, commands and operation outcomes belong to the content owner.
Live example
Current component with fictional data. Example changes are not persisted.
Responsibility
Trigger, overlay and named content form one modal-disclosure contract. A multi-field editor inside the dialog retains its own workflow and taxonomy. Portaled placement does not make that workflow part of the container's API.
Public contract
The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.
| Prop / part | Type | Requirement | Responsibility |
|---|---|---|---|
| container | Element | DocumentFragment | null | Content · optional | Radix Portal destination for content and overlay. Supply the owning theme or modal scope to preserve inherited tokens. Omitted retains Radix's document.body default; the caller owns element selection. |
| open / defaultOpen / onOpenChange | Radix Root props | Optional | Controlled or uncontrolled disclosure. |
| showCloseButton | boolean | Content · default true | Includes an accessible corner Close control. |
| showCloseButton | boolean | Footer · default false | Adds an outline Button wrapped by DialogClose. |
| children / className | Primitive or native props | Assembly supplied by consumer | Title, Description, Header and Footer complete the content contract. |
API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.
State and behavior
Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.
Radix supplies modal focus and open/close mechanics. The consumer owns the content, any draft, validation and async operation. Closing a container does not imply saving or network cancellation.
Dependencies
- Radix Dialog Root, Trigger, Portal, Overlay, Content, Title, Description and Close
- Button for optional footer close
- Lucide X
- cn()
Token and styling contract
These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.
bg-background / border / shadow-lg- Modal content surface.
bg-black/50 / z-50- Overlay and stacking utilities.
text-muted-foreground / text-lg- Description and title utilities.
Boundaries and limitations
- No submit, pending, error or draft lifecycle is exposed by Dialog itself.
- Disabling showCloseButton requires another explicit, accessible exit.
- Radix modal behavior cannot be demonstrated by a static card or native dialog as an exact specimen.
- The RoundSubmissionsView live example demonstrates container with a fictional tenant-theme scope. The default Dialog example keeps the document.body portal.
Where to make a change
Change shared modal anatomy in dialog.tsx. Keep command execution, form submission and draft policy in the content/controller. Focus, labels, layering and all indirect consumers need consideration when evolving the container.
Selected real uses
CommandDialog
Places the command interface in Dialog and supplies a title, description, open-state props and close-button configuration. This is shared disclosure structure, not evidence of a product command workflow.
src/components/ui/command.tsxThese traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.
Usage contract
import { Dialog, DialogTrigger, DialogContent, DialogTitle, DialogDescription } from "@/components/ui/dialog";
<Dialog><DialogTrigger>Read details</DialogTrigger>
<DialogContent><DialogTitle>Details</DialogTitle>
<DialogDescription>Consumer-supplied explanation.</DialogDescription>
</DialogContent>
</Dialog>Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.