Overview
Dialog is a modal dialog built on the native dialog element. It renders through a Portal and opens with showModal(), so the page behind it cannot be clicked or reached with Tab.
- Compound — Root, Title, Description, Content, Footer
- Named by its title —
Dialog.Title becomes the dialog's accessible name, and Dialog.Description its description. No extra props needed
- Focus return — when the dialog closes, focus goes back to the element that opened it
- Controlled — open state lives outside, through
isOpen and onClose. Escape also calls onClose; the dialog stays open until you set isOpen to false
- Motion — grows in from 96% with the backdrop fading in, and fades out before it leaves the page. With reduced motion, it only fades
- Fixed width — 360px, centered on screen
Basic Usage
Screen readers announce this as a dialog named "Replace the recorded time?", followed by the description.
Alert Dialog
Use role="alertdialog" for errors and confirmations that cannot be undone. It looks the same; screen readers announce it more urgently.
Keyboard
| Key | What happens |
|---|
| Open | Focus moves to the first focusable element inside the dialog |
| Tab | Moves between elements inside the dialog. The page behind is skipped |
| Escape | Closes the dialog and calls onClose |
| After close | Focus returns to the element that was focused before opening |
Closing by setting isOpen to false does not call onClose; focus still returns.
Sub-components
Dialog (Root)
| Prop | Type | Default | Required | Description |
|---|
isOpen | boolean | - | Yes | Whether it is open. true opens it with showModal(). false plays the exit animation, removes it, and returns focus to the element that had focus before it opened. |
onClose | () => void | - | Yes | Called on Escape (the browser close is prevented so the exit animation can run) and on the native close event. Set isOpen to false in it. |
children | ReactNode | - | Yes | Dialog.Title·Content·Description·Footer |
role | 'dialog' | 'alertdialog' | 'dialog' | No | Use alertdialog for confirmations that cannot be undone (such as delete) |
aria-label | string | - | No | Accessible name. Leave it out to use Dialog.Title. Set it only when the name must differ from the title. |
aria-describedby | string | - | No | Ids of extra describing elements. Joined with the Dialog.Description id. |
className | string | - | No | Extra CSS class |
Dialog.Title
| Prop | Type | Default | Required | Description |
|---|
children | ReactNode | - | Yes | Title text |
className | string | - | No | Extra CSS class |
Dialog.Description
| Prop | Type | Default | Required | Description |
|---|
children | ReactNode | - | Yes | Description text |
className | string | - | No | Extra CSS class |
Dialog.Content
| Prop | Type | Default | Required | Description |
|---|
children | ReactNode | - | Yes | Body content |
className | string | - | No | Extra CSS class |
| Prop | Type | Default | Required | Description |
|---|
children | ReactNode | - | Yes | Usually Buttons |
className | string | - | No | Extra CSS class |
Specification
base
| 상태 | 요소 | 속성 | 값 |
|---|
| enabled | root | padding | $size.space.400 |
| enabled | root | borderRadius | $size.radius.200 |
| enabled | root | gap | $size.space.400 |
| enabled | root | width | 360px토큰 아님 — no sizing token scale |
| enabled | title | typography | $text.bodyStrong |
| enabled | title | textAlign | center토큰 아님 — alignment is not tokenized |
| enabled | description | typography | $text.bodyBase |
| enabled | description | color | $color.text.brand.secondary |
| enabled | footer | gap | $size.space.400 |
Accessibility
- Always render a
Dialog.Title. Pass aria-label only when the name should differ from the visible title.
- Extra description elements can be added with
aria-describedby; they are read together with Dialog.Description.
ariaLabel and ariaDescribedby were renamed to the standard aria-label and aria-describedby.
Guidelines
- Place a maximum of 2–3 buttons in the Footer
- When
isOpen={false}, the dialog is removed from the DOM