Aliases
modal
components / dialog
Modal overlay surface with focus containment, backdrop dismissal, and tokenized sizing.
Playground
Start here. Switch systems, interact with the shipped component, and let the rest of the page answer the why and how after the behavior clicks.
Cobalt
The crisp default DK action system: bright primary, roomy spacing, and a direct editorial rhythm.
Overview
This section explains the intent of the component before the implementation details.
Aliases
modal
Explore the math
Decision guide
Use these notes to decide quickly whether this is the right DK component for the job.
Decision guide
Do
Do not
Usage
Prefer these situations when choosing this component.
Usage
These patterns are better served by a different component or a simpler surface.
Anti-patterns
Migration notes
Anatomy
The anatomy explains which pieces matter to the recipe and accessibility model.
open affordance
triggerControl that opens the dialog.
modal container
surfaceContains title, description, body, and footer.
actions row
footerOptional closing actions area.
API
The docs contract distinguishes props, DOM events, and slots so integration behavior is explicit.
Props
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Controlled open state. |
size | 'sm' | 'md' | 'lg' | 'md' | Chooses the dialog size recipe. |
title | string | — | Dialog title. |
description | string | — | Optional supporting explanation. |
closeOnEscape | boolean | true | Allows Escape to close the dialog. |
closeOnOutsidePress | boolean | true | Allows outside press dismissal. |
onOpenChange | (detail: { open: boolean }) => void | — | Callback fired when the dialog opens or closes. |
theme | ThemeContract | — | Overrides the compiled DK theme used to resolve tokens and recipes for this component. |
Events
| Name | Payload | Description |
|---|---|---|
openchange | { open: boolean } | Fires when an overlay-style component opens or closes through user interaction. |
Slots
| Name | Description |
|---|---|
trigger | Optional trigger content. |
default | Dialog body content. |
footer | Optional footer actions. |
Recipes
These notes summarize the intended recipe surface rather than exposing raw implementation detail first.
Variants
Sizes
States
Accessibility
This is the behavior the component promises to assistive tech and keyboard users today.
Semantics
Keyboard
Screen readers
Checklist
Implementation
This section shows the representative compiled slot variables that the runtime consumes for the selected design system.
Implementation notes
Implementation checklist
Examples
Each example is intentionally practical, grouped by starter, common pattern, and edge-case coverage.
Starter
1 example
starter
Starter: confirm actionA standard confirm/review modal.
Copy snippet
<Dialog title="Release notes" description="Confirm the publication details before shipping."><svelte:fragment slot="trigger">Open dialog</svelte:fragment>Review the release details.</Dialog>Common patterns
1 example
common
Common: explicit footer actionsUse a footer when the decision needs multiple clear next steps.
Copy snippet
<Dialog title="Confirm delete"><svelte:fragment slot="footer"><Button variant="ghost">Cancel</Button><Button variant="destructive">Delete</Button></svelte:fragment>Review the consequences before continuing.</Dialog>Edge cases
1 example
edge
Edge: controlled modal stateControl open state when product logic owns the workflow.
Copy snippet
<Dialog open={isOpen} onOpenChange={(detail) => isOpen = detail.open} title="Release notes">Review details</Dialog>Verification
Proofs stay visible in the docs so the system shows what it can guarantee, not just what it can render.
size=sm
size=md
size=lg