Dialog
Dialog is a content structure component that provides a consistent layout for a title, body content, and actions, and it is designed to be used inside Modal or BottomSheet components; it does not provide overlay, backdrop, or focus management on its own.
Dialog Title
Code example
import { Dialog, Button } from '@yleisradio/yds-components-react';
<Dialog
title="Dialog Title"
actions={
<>
<Button text="Cancel" variant="text" />
<Button text="Confirm" />
</>
}
>
Dialog content goes here
</Dialog>
Why to use
Use Dialog to ensure consistent spacing, typography, scrolling behavior, and action placement across all dialog-based interfaces in YDS. Dialog standardizes dialog layout, handles internal scrolling and separators, aligns actions consistently across devices, and improves accessibility when used inside Modal or BottomSheet.
Dialog is a building block component designed to work inside Modal or BottomSheet. It provides the content structure (title, body, actions) but does not provide modal behavior, backdrop, or focus management. Use Modal or BottomSheet for the actual dialog overlay functionality.
When to use
Use Dialog when you need a structured dialog layout that consists of a clear title, body content, and optional actions.
- Use Dialog inside Modal or BottomSheet for all dialog interfaces.
- Use it for confirmations, forms, settings, and focused tasks.
- Use when content needs a clear hierarchy and actions footer.
- Don’t use Dialog as a standalone modal overlay.
- Don’t use it for generic layout or page content.
- Don’t omit the title — it is required for accessibility.
Content Guidelines
Use these guidelines when placing content inside a Dialog. They are based on the Modal content guidelines.
- Write a clear, descriptive title that explains the task.
- Keep body content concise and task-focused.
- Match the primary action label to the dialog intent
- Action buttons should have clear, descriptive labels that indicate their purpose.
- Don’t overload the dialog with secondary content.
- Don’t include multi-step flows inside a dialog.
- Don’t use vague action labels like “OK”.
Key Dialog Props
Use these props to configure the Dialog component.
title
Dialog title text.
| Type | Example | Description |
|---|---|---|
string | Confirm ActionContent | Title text for the dialog |
Code example
<Dialog
title="Confirm Action"
actions={
<>
<Button variant="text" text="Cancel" />
<Button text="Confirm" />
</>
}
>
Are you sure you want to proceed?
</Dialog>
titleAs
HTML tag name to render for the title.
| Type | Example | Description |
|---|---|---|
string | Dialog TitleContent | HTML element for title (e.g., 'h2') |
Code example
<Dialog
titleAs="h2"
title="Dialog Title"
actions={
<>
<Button variant="text" text="Cancel" />
<Button text="Confirm" />
</>
}
>
Content
</Dialog>
illustrativeIcon
Optional illustrative icon displayed above the title.
| Type | Example | Description |
|---|---|---|
React.ReactElement<SvgProps> | null | TitleContent | Illustrative icon element to display |
Code example
import { IllustrativeCelebrate } from '@yleisradio/yds-icons-react';
<Dialog
illustrativeIcon={<IllustrativeCelebrate />}
title="Dialog Title"
actions={
<>
<Button variant="text" text="Cancel" />
<Button text="Confirm" />
</>
}
>
Content
</Dialog>
size
Size variant of the dialog.
| Value | Example | Description |
|---|---|---|
sm | TitleContent | Small dialog size |
md | TitleContent | Medium dialog size (default) |
Code example
<Dialog size="sm" title="Small Dialog" actions={<Button text="Action" />}>
Content
</Dialog>
<Dialog size="md" title="Medium Dialog" actions={<Button text="Action" />}>
Content
</Dialog>
actions
Action buttons or elements displayed in the footer.
| Type | Example | Description |
|---|---|---|
React.ReactNode | TitleContent | Footer action elements |
Code example
<Dialog
title="Confirm"
actions={
<>
<Button variant="text">Cancel</Button>
<Button>Confirm</Button>
</>
}
>
<p>Are you sure?</p>
</Dialog>
Behavior
- Dialog provides layout only — no open/close logic.
- Body content scrolls independently when height exceeds limits.
- Scroll separators appear automatically when content overflows.
- Actions remain visually separated from content.
- Action buttons in the
actionsprop are automatically sized to match the dialog'ssizeprop - Illustrative icons are positioned above the title and affect spacing accordingly
- The component is purely presentational — it does not handle opening, closing, or modal behavior (that's handled by Modal or BottomSheet)
Accessibility
- Title is rendered as a heading (default
h2, configurable viatitleAsprop) for proper document structure
(WCAG 1.3.1 — Info and Relationships) - Structure supports screen reader announcement when used in Modal/BottomSheet.
- Illustrative icons are decorative and don't require alt text (they're visual enhancements)
API Reference
Props
The Dialog component accepts all standard HTML <div> attributes in addition to the following props:
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
title | string | Yes | — | Dialog title text |
titleAs | string | No | 'h2' | HTML tag name to render for title |
illustrativeIcon | React.ReactElement<SvgProps> | null | No | — | Optional icon displayed above title |
size | 'sm' | 'md' | No | 'md' | Size variant of the dialog |
children | React.ReactNode | No | — | Content displayed in dialog body |
actions | React.ReactNode | No | — | Action buttons displayed in footer |
Type Definitions
import { type SvgProps } from '@yleisradio/yds-icons-react';
export interface DialogDSProps {
title: string;
titleAs?: string;
illustrativeIcon?: React.ReactElement<SvgProps> | null;
size?: 'sm' | 'md';
children?: React.ReactNode;
actions?: React.ReactNode;
}
export type DialogProps = HTMLAttributes<HTMLDivElement> & DialogDSProps;
Related Components
- Modal – Primary container for Dialog — use Modal to wrap Dialog for desktop/tablet dialog interfaces.
- BottomSheet – Primary container for Dialog — use BottomSheet to wrap Dialog for mobile dialog interfaces.
- Button – Commonly used in dialog
actionsprop for footer buttons. - Accordion – Can be used inside a Dialog to organise collapsible content.