A dialog is a temporary window that appears on top of the main content of an application, requiring user interaction before the underlying content can be accessed again.
Dialog component can be controlled by open and onClose props.Dialog component can be self-closed by 3 reasons specified in the DialogCloseReason type: outside-press | escape-key | close-icon.Dialog component requires at least one DialogContent and one DialogAction to render.Dialog component is fit-content. To make it full of available width, set the fullWidth prop to true.maxWidth prop to predefined values: xs, sm, md, lg, xl.maxWidth value is sm.Max width | Value |
|---|---|
| 448px |
| 608px |
| 924px |
| 1240px |
| 1556px |
closeIcon prop.hideCloseIcon prop to true.closeByEscape prop to false.closeByOutsideClick prop to false.closeButton prop.Dialog component as a child of another Dialog component.initialFocus prop.initialFocus prop can be either a number (tabbable index as specified by the order) or a ref.When dialogs become too long for the user’s viewport or device, the content of the DialogContent will be scrollable.
<body> scroll and return focusBy default, main content area is dimmed and scrolling is disabled. You can control scrolling behavior using the lockscroll prop.
When a dialog is open, returnFocus prop determines whether the focus should be returned to the element that initiated the dialog or if the current screen position should be preserved.
Default value for both lockScroll and returnFocus are true.
Dialog component follows WAI-ARIA recommendations on accessibility.
Dialog is a regular div[role="dialog"] element. It has states and props as follows:
aria-modal attribute set to true.aria-labelledby attribute set to the id of the DialogHeader component.aria-describedby attribute set to the id of the DialogContent component.Key | Function | Condition |
|---|---|---|
| Moves focus to next focusable element inside the dialog. | When focus is on the last focusable element in the dialog, moves focus to the first focusable element in the dialog. |
| Moves focus to previous focusable element inside the dialog. | When focus is on the first focusable element in the dialog, moves focus to the last focusable element in the dialog. |
| Closes the dialog. |