Component
A dialog that is used to display a message to the user. It is used to display information and let the user interact with the content.
View component changelog- Traps focus while open and returns it to the trigger on close
- Escape closes only the top dialog when dialogs are nested
- Nested dialogs expose data-nested, data-nested-dialog-open and --nested-dialogs for stacked styling
- Supports CSS enter and exit transitions with data-starting-style and data-ending-style
Import all parts of the component and piece them together
The root component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | -- |
customRootClass | string | -- |
open | boolean | -- |
children | ReactNode | -- |
defaultOpen | boolean | false |
onOpenChange | (open: boolean, details) => void | -- |
onClickOutside | function | -- |
handle | Handle | -- |
onOpenChangeComplete | (open: boolean) => void | -- |
modal | boolean | 'trap-focus' | true |
actionsRef | Ref<{ close(): void }> | -- |
triggerId | string | null | -- |
defaultTriggerId | string | null | -- |
The trigger component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | -- |
asChild | boolean | false |
handle | Handle | -- |
payload | unknown | -- |
The portal component for the Dialog.
| Prop | Type | Default |
|---|---|---|
children | ReactNode | -- |
container | Element | null | -- |
forceMount | boolean | false |
keepMounted | boolean | false |
The overlay component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
asChild | boolean | false |
forceMount | boolean | false |
The content component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
children | ReactNode | -- |
asChild | boolean | false |
forceMount | boolean | false |
initialFocus | boolean | RefObject<HTMLElement> | () => HTMLElement | boolean | true |
finalFocus | boolean | RefObject<HTMLElement> | () => HTMLElement | boolean | true |
trapFocus | boolean | true |
The title component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
children | ReactNode | -- |
The description component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
children | ReactNode | -- |
A layout container for dialog actions.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
The close component for the Dialog.
| Prop | Type | Default |
|---|---|---|
className | string | '' |
children | ReactNode | -- |
asChild | boolean | false |
| Shortcut | Description |
|---|---|
Escape | Closes the dialog when the close interaction is enabled. |
Tab | Moves focus to the next focusable element inside the dialog. |
Shift + Tab | Moves focus to the previous focusable element inside the dialog. |
| Reference | What Rad UI follows |
|---|---|
Uses modal dialog semantics with labelled content, description support, focus containment, and dismiss behavior. |