Skip to main content
Saved
Guide implementation Intermediate 4 min read

Accessible Interaction Playbook

Making interactive UI accessible, with focus management, keyboard support, and screen reader announcements.

Semantic HTML is essential, but a lot of accessibility problems only appear once users start interacting with the page. Once users open a modal, focus needs to stay inside it, and once they submit a form, screen readers need to announce what happened. Your application’s static markup might be fine while these interactions still cause problems, so this guide goes through each of them.

Manage Focus Deliberately

Keyboard users navigate your interface by moving focus. If focus isn’t managed well, keyboard users can lose track of where they are on the page, and they might not be able to work out how to get to the interactive elements.

  • Create clear focus paths: Each screen needs one logical tab order. With Focus Management, you can trap focus inside a modal, so that while it’s open, keyboard users can’t tab onto the page behind it.
  • Add skip links: Skip Links at the top of your page let keyboard users jump straight to the content, instead of tabbing through lots of navigation links.
  • Design for focus first: It’s easier to work out the focus order while you’re designing a screen than at the end of development. If your team annotates wireframes with the tab order, the focus order gets decided along with the rest of the design, instead of being patched in later.

Make Everything Keyboard Accessible

Keyboard support is part of your application’s core functionality, so if users can click something with a mouse, they should be able to activate it with a keyboard too.

  • Implement full keyboard support: With Keyboard Navigation, every interactive element responds to Enter, Space, and the arrow keys where it makes sense. Focus states should be visible, and your code shouldn’t intercept screen reader shortcuts, because that frustrates the people who use them.
  • Keep shortcuts optional: Keyboard shortcuts are a convenience, so it’s best to only add one when there’s also a mouse or touch alternative, and to let users customize or disable them.
  • Test without a mouse: It’s worth unplugging your mouse and trying to use your application with only the keyboard. If you find it hard, users who navigate this way every day will find it hard too, and anything that only works with a mouse is an accessibility bug.

Announce Dynamic Changes

Screen reader users can’t see visual feedback such as a success toast or a loading indicator, so unless your application announces it, they can’t tell whether their action worked.

  • Use live regions: Live Regions let you announce toasts and loading states. Screen readers read them out without moving the user’s focus away from what they’re doing.
  • Limit announcements: If your application announces each state change, users can get overwhelmed, so it’s best to save announcements for errors and confirmations.
  • Test translated announcements: It’s worth testing your announcements in other languages too, because a short English message might turn into a much longer one once it’s translated. A longer message takes longer to read out, and the visible text might no longer fit in the toast.

Respect Motion Preferences

Animations that some users enjoy can make others feel sick or disoriented, and that’s why operating systems have a reduced motion setting, which your CSS and JavaScript can check with the prefers-reduced-motion media query.

  • Honor reduced motion: With Accessible Animation, your code checks whether users have reduced motion enabled, and if they do, it shows simple fades or instant transitions instead of elaborate animations.
  • Keep animations purposeful: Animations should communicate something useful, such as loading progress or a change of state. Purely decorative animations should be the first to go when users prefer reduced motion. Auto-playing sound and strong haptic feedback can cause problems too, so it’s best to avoid them.

Design for Screen Readers

Screen readers read the interface out loud, and how easy that is to follow depends on how well the markup is structured.

  • Use proper ARIA: The Screen Reader pattern covers giving elements the correct roles, labels, and states. When a button expands a section, its aria-expanded value should change at the same moment, because that value is how a screen reader knows to tell the user the section is now open.
  • Provide context: As users tab into a complex component such as a data grid, it helps to announce which keyboard shortcuts are available. Otherwise users have no way to know that a custom widget expects the arrow keys instead of Tab.

Make Accessibility Routine

If you leave accessibility to an audit at the end of development, the fixes usually get rushed in afterward and aren’t done well, so it works better to build it in from the start.

  • Define requirements upfront: It helps to add accessibility criteria to your feature specifications, and to document where focus should move and what gets announced. If something isn’t in the spec, it usually doesn’t get built.
  • Test regularly with assistive tech: I suggest using VoiceOver, NVDA, JAWS, or TalkBack at least once a week. They each behave a little differently, and if you use them regularly, you’ll find problems during development instead of after a release.
  • Automate what you can: axe-core can catch common issues automatically, and integration tests can check that focus moves where it should. You still need manual testing for the problems that only a person would notice.

Remember: The World Health Organization estimates that 1.3 billion people, about 16% of the world’s population, live with a significant disability. The same focus handling and announcements that help them make the interface easier to use for everyone else too.

Next Guide · 6 min read

Building with Progressive Enhancement

A guide to building web applications that keep working for everyone, whatever their browser supports.

Read the next guide →

Keep Exploring

A monthly email
from Den Odell.

What I'm thinking about frontend patterns, plus news when the site changes.

No spam. Unsubscribe anytime.