05 / 13

How do you make a modal fully accessible

Making an Accessible Modal

A modal dialog should be usable by everyone, including keyboard-only and screen reader users. Accessibility requires handling focus, roles, labels, and keyboard interaction properly.

Key Accessibility Features for Modals
  1. 1

    Focus Management – Move focus into the modal when it opens and return it to the triggering element when it closes.

  2. 2

    Focus Trap – Keep focus inside the modal while it is open, preventing users from tabbing into the page behind it.

  3. 3

    Keyboard Support – Allow closing with the Escape (Esc) key, and ensure all interactive elements are reachable with Tab/Shift+Tab.

  4. 4

    ARIA Roles – Use role="dialog" or role="alertdialog" to announce the modal as a dialog to screen readers.

  5. 5

    Accessible Labels – Provide a clear label using aria-labelledby (for the modal title) and aria-describedby (for extra instructions or content).

  6. 6

    Background Inertness – Hide or mark the page content outside the modal as inert/inaccessible while the modal is open.

These practices ensure users can navigate, understand, and dismiss the modal without confusion or barriers.

Best Practices
  1. 1

    Always return focus to the element that opened the modal.

  2. 2

    Ensure modal content is concise and focused on a single task.

  3. 3

    Don’t rely on color or visuals alone—make instructions text-based as well.

  4. 4

    Test with a screen reader and keyboard to confirm expected behavior.