Dialog
A controlled alert dialog for explicit decisions, with slotted title and supporting-copy parts, a required primary action, an optional safe secondary action, and an optional transient error region.
Implementation previewEvery example. In one place.
Explore every named example, including states, compositions, and theme variants.
Example source
packages/design-system/src/components/overlays/Dialog/Dialog.stories.tsxExport DestructiveImplementation preview Local Storybook build 0.2.0-preview.1. Source specification status does not approve this runtime.
Stories + source JSON ↗Local specification source status: preview. Implementation preview pending sign-off.
A controlled alert dialog for explicit decisions, with slotted title and supporting-copy parts, a required primary action, an optional safe secondary action, and an optional transient error region.
Implementation API 4 entry points · source-derived preview
Read the actual callable API and preserve its composition constraints. Each union branch is a complete alternative; props marked forbidden cannot be supplied.
import { Dialog } from '@cloakedinc/design-system';DialogDialogProps
packages/design-system/src/components/overlays/Dialog/Dialog.tsx:64
| Prop | Type | Presence | Notes |
|---|---|---|---|
isOpen | boolean | Required | Presents the surface when true; closing remains mounted until the exit animation completes. |
children | [React.ReactElement<DialogTitleProps, string | React.JSXElementConstructor<any>>, React.ReactElement<DialogBodyProps, string | React.JSXElementConstructor<any>>] | Required | The title and body slots, in that order. |
primaryAction | DialogPrimaryAction | Required | Required confirming or acknowledging action; it never receives initial focus. |
secondaryAction | DialogSecondaryAction | undefined | Optional | Optional safe action; when enabled, it receives initial focus. |
error | string | undefined | Optional | Transient failure from the last action attempt. Kept out of `aria-describedby`. |
testId | string | Required | Root selector used to derive slot, action, and overlay test ids. |
portalTarget | HTMLElement | null | undefined | Optional | Portal mount node. Defaults to `document.body`. |
Dialog.TitleDialogTitleProps
packages/design-system/src/components/overlays/Dialog/DialogTitle.tsx:16
| Prop | Type | Presence | Notes |
|---|---|---|---|
children | string | Required | Doubles as the alertdialog's accessible name. |
Dialog.BodyDialogBodyProps
packages/design-system/src/components/overlays/Dialog/DialogBody.tsx:20
| Prop | Type | Presence | Notes |
|---|---|---|---|
children | React.ReactElement<DialogDescriptionProps, string | React.JSXElementConstructor<any>> | React.ReactElement<DialogDescriptionProps, string | React.JSXElementConstructor<any>>[] | Required | One description per paragraph; the body owns the spacing between them. |
Dialog.DescriptionDialogDescriptionProps
packages/design-system/src/components/overlays/Dialog/DialogDescription.tsx:20
| Prop | Type | Presence | Notes |
|---|---|---|---|
children | string | Required | Plain copy for one paragraph. Multi-paragraph content is sibling descriptions, not markup. |
color | "primary" | "secondary" | undefined | Optional | Drops a paragraph to secondary text. Hierarchy in a dialog comes from color and order, so
the paragraph the reader must not skim past stays primary and sits last, next to the actions.Source default: 'primary' |
Only explicit destructured parameter initializers are extracted. Other runtime defaults remain in implementation source.
Overview
A controlled confirmation surface for decisions that require an explicit action. A title slot, a body slot, and a primary action are required. Add a secondary safe action when the context needs one.
Composition
Copy is slotted, not passed as props. Dialog.Title and each Dialog.Description
take plain strings, so a dialog can carry several paragraphs without the surface
accepting arbitrary markup.
<Dialog isOpen={isOpen} testId='chat-disable-dialog' primaryAction={confirm} secondaryAction={cancel}>
<Dialog.Title>Turn off the assistant?</Dialog.Title>
<Dialog.Body>
<Dialog.Description color='secondary'>We'll immediately delete every chat.</Dialog.Description>
<Dialog.Description>Once deleted, this cannot be recovered.</Dialog.Description>
</Dialog.Body>
</Dialog>
Hierarchy comes from color and order, not weight: color='secondary' drops the
supporting paragraphs back so the one consequence the reader must not skim past
keeps primary text and sits last, directly above the actions. There is no bold
paragraph to reach for — a <strong> tag would inherit the user-agent 700 and a
shared emphasis variant would be reachable from anywhere.
The actions stay props on purpose. Their order, focus, and tone are the alert
grammar this component exists to enforce, so they are not open to composition.
Dialog.Body owns the aria-describedby target, which keeps the accessible
description to the copy and excludes the title.
Behavior
Dialog does not dismiss from the backdrop or Escape. The caller owns isOpen
and closes it from an action callback. Focus moves to an enabled secondary
action, or to the dialog itself when no safe action is available, and returns to
the launcher after the close animation.
Pass error when the last action attempt failed. It renders in a role="alert"
region below the copy and stays out of aria-describedby, so a retryable message
is announced once rather than joining the dialog's standing description.
Usage by variant
| Choice | Use when | Avoid when |
|---|---|---|
Configuration: Two actions | The user can safely cancel or confirm. The enabled secondary action receives initial focus. | |
Configuration: Primary only | The user only needs to acknowledge a completed or informational state. | High-risk actions where the user needs a clear way to cancel. |
Component specification
$schema
../../../specs/component-spec.schema.jsonParts
- Id
- root
- Label
- Root
- Description
- Centered alert-dialog surface containing the decision content and actions.
- Required
- true
- Id
- overlay
- Label
- Overlay
- Description
- Modal backdrop behind the dialog.
- Id
- title
- Label
- Title
- Description
- Required heading slot that names the decision and supplies the accessible name.
- Required
- true
- Id
- body
- Label
- Body
- Description
- Required supporting-copy slot. It stacks one or more description paragraphs and is the target of the dialog's accessible description.
- Required
- true
- Id
- description
- Label
- Description
- Description
- One paragraph of plain supporting copy. Multi-paragraph content is sibling descriptions. A paragraph may drop to secondary text so the paragraph that must not be skimmed past reads first.
- Required
- true
- Id
- primary-action
- Label
- Primary action
- Description
- Required confirming or acknowledging action.
- Required
- true
- Id
- secondary-action
- Label
- Secondary action
- Description
- Optional safe or cancelling action.
- Id
- error
- Label
- Error
- Description
- Optional transient failure from the last action attempt, announced on appearance.
Allowed Design Choices
- Variants
- Default
- Label
- Default
- Description
- Centered explicit-action dialog with default or danger primary-action tone.
- Sizes
Variants
- Id
- default
- Label
- Default
- Description
- Centered modal decision surface.
- Platforms
- ios
- android
- web
Sizes
None specifiedMeasurements
- Id
- overlay-inset
- Label
- Overlay inset
- Kind
- exact
- Token
- --cds-space-24
- Value
- 24
- Unit
- px
- Applies To
- overlay
- Id
- dialog-maximum-width
- Label
- Dialog maximum width
- Kind
- at-most
- Token
- --cds-size-320
- Value
- 320
- Unit
- px
- Applies To
- root
- Id
- dialog-padding
- Label
- Dialog padding
- Kind
- exact
- Token
- --cds-space-24
- Value
- 24
- Unit
- px
- Applies To
- root
- Id
- content-action-gap
- Label
- Content-to-action gap
- Kind
- exact
- Token
- --cds-space-16
- Value
- 16
- Unit
- px
- Applies To
- root
- Id
- title-description-gap
- Label
- Title-to-description gap
- Kind
- exact
- Token
- --cds-space-8
- Value
- 8
- Unit
- px
- Applies To
- title
- body
- Id
- action-gap
- Label
- Action gap
- Kind
- exact
- Token
- --cds-space-8
- Value
- 8
- Unit
- px
- Applies To
- primary-action
- secondary-action
- Id
- corner-radius
- Label
- Corner radius
- Kind
- exact
- Token
- --cds-radius-2xl
- Value
- 32
- Unit
- px
- Applies To
- root
- Id
- description-gap
- Label
- Paragraph gap
- Kind
- exact
- Token
- --cds-space-8
- Value
- 8
- Unit
- px
- Applies To
- body
- description
Layout
- Alignment
- The overlay centers the dialog in the available viewport while allowing vertical scrolling when content is taller than the viewport.
- Flow
- The title and the stacked description paragraphs sit above an optional error region and then either one full-width primary action or a wrapping row containing the safe secondary action followed by the primary action.
- Notes
- Two actions remain side by side while their labels fit and wrap into a stack with the primary action first when space is constrained.
Typography And Color
- Typography
- Label
- Title
- Description
- The dialog title uses the h4 ramp.
- Token
- --cds-type-h4-size
- Label
- Description
- Description
- Each description paragraph uses the body-small ramp.
- Token
- --cds-type-body-small-size
- Colors
- Label
- Surface
- Description
- The dialog uses the raised surface background.
- Token
- --cds-bg-surface
- Label
- Primary text
- Description
- The title and default supporting content use primary text.
- Token
- --cds-text-primary
- Label
- Secondary text
- Description
- A description paragraph subordinate to the consequence uses secondary text.
- Token
- --cds-text-secondary
- Label
- Overlay
- Description
- The modal backdrop uses the shared overlay token.
- Token
- --cds-overlay-backdrop
- Label
- Error text
- Description
- The transient error region uses danger text.
- Token
- --cds-status-danger-solid
States
- Id
- closed
- Label
- Closed
- Description
- Not mounted after the exit animation completes.
- Id
- open
- Label
- Open
- Description
- Mounted as a modal alert dialog with actions available.
- Id
- primary-loading
- Label
- Primary loading
- Description
- The primary action communicates pending work and blocks repeated activation.
- Id
- action-disabled
- Label
- Action disabled
- Description
- Either action may be disabled while its operation is unavailable.
- Id
- error
- Label
- Error
- Description
- The last action attempt failed and the dialog shows a retryable message.
Behavior
- Label
- Controlled visibility
- Description
- The caller owns isOpen and closes the dialog from an action callback.
- Label
- Explicit decision
- Description
- Backdrop interaction does not dismiss the dialog; the user chooses an action.
- Label
- Slotted content
- Description
- Copy is composed from a title slot and one description slot per paragraph, each taking plain text. The surface accepts no arbitrary markup, so multi-paragraph dialogs stay on the type ramp; a description sets its rank through primary or secondary text color instead of inline markup.
- Label
- Action priority
- Description
- Use the danger primary-action tone for irreversible actions and provide a safe secondary action when cancellation is meaningful.
- Label
- Transient error
- Description
- An error from the last action attempt is announced through an alert region and is kept out of the dialog's standing accessible description.
Accessibility
- Label
- Alert dialog semantics
- Description
- The root uses alertdialog and aria-modal, is named by the title slot, and is described by the body slot, which contains only the supporting paragraphs.
- Label
- Focus placement
- Description
- An enabled safe secondary action receives initial focus when present; otherwise the dialog surface receives focus. Closing restores focus to the launcher. The surface suppresses the focus outline: the runtime is touch-only, so a ring around the whole card signals nothing.
- Label
- Action labels
- Description
- Both actions expose their visible labels through the shared Button primitive.
Content Adaptation
- Label
- Multi-paragraph copy
- Description
- Split supporting copy into one description per paragraph when separate points communicate consequences more clearly.
- Label
- Long action labels
- Description
- The two-action row wraps into a vertical stack instead of clipping or shrinking labels.
- Label
- Viewport constraints
- Description
- The overlay scrolls vertically when the dialog cannot fit within the available viewport.
- Label
- Ranked paragraphs
- Description
- When a dialog carries several paragraphs, drop the supporting ones to secondary text and keep the irreversible consequence in primary text as the last paragraph before the actions.
Motion Haptics
- Motion
- Label
- Presentation
- Description
- The overlay fades in while the dialog fades and scales to its resting size; scaling is removed under reduced motion.
- Haptics
- Label
- Actions
- Description
- Dialog actions inherit the shared Button haptic behavior.