Skip to main contentCarbon Design System

Modal

Design annotations are needed for specific instances shown below, but for the standard modal dialog component, Carbon already incorporates accessibility.

What Carbon provides

Carbon bakes keyboard operation into its components, improving the experience of blind users and others who operate via the keyboard. Carbon incorporates many other accessibility considerations, some of which are described below.

Keyboard interactions

Modal dialogs take focus on appearance, and the tab order is constrained to the modal’s controls until the modal is closed by choosing one of the buttons with Enter or Space, or is dismissed by pressing Esc.

illustration showing tab ring constrained within a modal with two buttons

Keyboard navigation is constrained to the dialog. Tab cycles through the components that take focus.

Esc closes a modal, while Space and Enter keys activate buttons

The dialog is resolved by the user pressing Esc or activating a button.

When the dialog appears, the first item that gets focus depends on the type of dialog. Passive dialogs only contain a close button (X), so that takes focus. For dialogs which prompt for confirmation or user decision, the primary button takes focus. For destructive interactions, the “cancel” button takes focus, not the red danger/delete button. The tab order should proceed left and down from whichever item has focus before wrapping back to the Close button (X).

initial focus in the dialog varies across four types of modals

The first item with focus varies depending on dialog type.

Design recommendations

Designate the first input to take focus in a transactional

The only time the starting focus would not be on a button is where a dialog contains input fields. For such transactional dialogs, designers should annotate that the first input field should receive focus. Note that text links are not considered a user input in this context.

an annotation, connecting an IBM Cloud heading with a Learn more link, reads "associate modal dialog with heading"

Annotate the connection between generic links and text that gives context.

Development considerations

Keep these considerations in mind if you are modifying Carbon or creating a custom component.

  • Associate generic links such as “read more” with other contextual text, using either aria-describedby or aria-labelledby (to concatenate multiple text strings). See the Equal Access Toolkit guidance for more details.
  • See the ARIA authoring practices for more considerations.