Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Dialog

Keys, what Dialog gives you and what your team does.

Conformance

Dialog meets WCAG 2.2 level AA when used as described on these pages. It follows the Dialog (Modal) pattern of the WAI-ARIA Authoring Practices.

Keyboard

Key Action
Tab Moves to the next control in the dialog; from the last, back to the first.
Shift + Tab Moves to the previous control, wrapping the same way.
Esc Closes the dialog. Focus returns to the trigger.
Enter In a form, submits it.

What Dialog gives you

  • role="dialog" and aria-modal="true", named by DialogTitle and described by DialogDescription.
  • Focus moves into the dialog when it opens, stays inside while it is open, and returns to the trigger when it closes.
  • The page behind is hidden from screen readers and can’t be scrolled.
  • The close button has a name (closeLabel) and the Button’s focus ring.
  • Title and text 7:1 or more on the surface.

What your team does

  • Always put a DialogTitle in the dialog. Hide it visually only if the design has no visible title.
  • Translate closeLabel with the page.
  • Wrap fields in a <form> so Enter submits.
  • Order the footer buttons Cancel, then the primary action (D10).

WCAG criteria

Criterion Level How
1.3.1 Info and Relationships A Title and description linked to the dialog
2.1.1 Keyboard A Every control reachable; Esc closes
2.1.2 No Keyboard Trap A Esc and the buttons always close it
2.4.3 Focus Order A Focus moves in on open and back to the trigger on close
2.4.7 Focus Visible AA Focus ring on every control
4.1.2 Name, Role, Value A role="dialog", aria-modal, aria-labelledby, aria-describedby