Skip to main content

An official website of the United States government

Here's how you know

An official website of the United States government

Here's how you know

Theme:

Design system switcher

Version:

Design system switcher

Theme:

Design system switcher

Version:

Design system switcher

Modal Dialog

The dialog component can be used to focus a user's attention on a single piece of content, without taking them to a new screen. Please use with caution; view our guidance for more details.

Examples

Loading

Dialog size variants

Apply one of the size modifier classes to the ds-c-dialog element to change the dialog width.

  • .ds-c-dialog--narrow
  • .ds-c-dialog--wide
  • .ds-c-dialog--full

Code

React

Preact/React documentation for Storybook

Style customization

The following CSS variables can be overridden to customize Dialog components:

CSS variables for dialog
VariableDefault Core Theme Value
--dialog__background-colorhex value: #ffffff--color-white
--dialog__padding32px
--dialog-overlay__background-colorhex value: #00000080--color-transparent-black-alpha50
--dialog-icon__size0.8125rem

Analytics

This component has analytics tracking available. Please see our developer documentation about using analytics in the design system.

Guidance

Accessibility

Keyboard support

  • Enter or Space to select the highlighted item.
  • Tab to move the focus sequentially through the list of focusable items.
  • Shift + Tab to move the focus sequentially through the list of focusable items in reversed order.

Focus Management

  • When the modal is opened, the entire modal is the default focus state. Most screen readers will announce the entire dialog content.
  • Focus is trapped within the modal and users can then navigate through the dialog actions with the keyboard.
  • Escape will close the modal. To disable exiting when users press the Escape key, set the escapeExits prop to false
  • When the modal closes, focus returns to the element that was focused just before the modal is activated
  • To place the focus inside of the dialog on activating the modal, set the dialog focus using the initialFocus prop with boolean prop focusDialog set to false

Learn more

Component maturity

This component meets 100% of our maturity criteria.

What does this mean?

Each component is tested against the following items to gauge the component's maturity. When using incomplete components, consider the unmet criteria as applied to your product.

For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.