Skip to main content

Accessibility

Common issues

  • Improper tab navigation
  • Unclear focus states
  • Focus traps / losing focus
  • Non-descriptive screen reader support

Best Practices

Tab navigation

  • Users should be able to navigate your application and perform all necessary actions through tab navigation
    • Sub-items accessible by arrow keys
    • Items offscreen when tabbed to will move the window to bring it on-screen
  • Should be ordered logically, with tabIndex if needed
    • Remove items with tabIndex={-1}
      • Add items with tabIndex={0}
      • Tab indexes above 0 can be used to manually order elements, but it's not recommended
  • Use header tags for longer blocks of content (h1, h2, h3)
    • Some screen readers let users jump between sections based off the header tags
  • Focus traps
    • Some components like rich text fields may "trap" focus, not allowing a tab press to advance focus
    • If you are creating a "focus trap" make sure the user is able to escape out to continue navigation
    • Also check when entering / exiting submenus

Focus indication

Screen readers

Using prebuilt components

  • If you use a prebuild / library component, don't assume that it will follow accessibility guidelines
    • Sometimes they just aren't compliant, or we use it in a way that messes with the accessibility
  • Most fluent components are already compliant with WCAG guidelines

Dialogues / Panels / Surfaces

  • When new surfaces are rendered, be sure to test the focus and screen reader interactions
  • Focus should be moved to the first element on the surface
  • Screen readers should announce what happened when a surface opens / closes
    • ie. Announce that a dialogue opened, read the dialogue title, read the first element focused
  • Decide on if the surface needs to trap focus, or if the user should be able to leave and access other elements

Other tips


Helpful tools

Browser devtools "Lighthouse"

Helpful way to analyze snapshots of your page

Lighthouse Image

"taba11y" browser extension

Helpful to see tab flow all at once, also provides some info on other accessible properties easily Chrome webstore link

Taba11y Image