DEV Community

Cover image for Accessible Accordions and Tabs: The Two Patterns Everyone Confuses
Denis Omerovic
Denis Omerovic

Posted on • Originally published at getaccessguard.com

Accessible Accordions and Tabs: The Two Patterns Everyone Confuses

Accordions and tabs look almost identical when you squint, but they're not the same pattern. Different ARIA roles, different keyboard contracts, different reasons to exist — and one of the fastest ways to ship a broken component is to build one with the rules for the other.

I wrote up the full breakdown on the AccessGuard blog: how to pick the right pattern, the WCAG criteria each one touches, the exact markup that makes them accessible, and the bugs that show up most often in real-world scans.

Read the full post here 👉 https://getaccessguard.com/posts/accessible-accordions-and-tabs-two-patterns-everyone-confuses

Quick teaser of what's covered:

  • When to use an accordion vs a tabset (it's structural, not visual)
  • Accordion: real <button> inside a real heading, aria-expanded, aria-controls, and the hidden attribute
  • Tabset: role="tab", roving tabindex, and the Arrow / Home / End keyboard model that nothing else on the web uses
  • Why mobile "tabset that collapses into an accordion" needs a markup swap, not just a CSS swap
  • A 5-minute keyboard test you can run before shipping

If you maintain a component library or you're about to reach for an accordion in your next sprint, this one's for you.

Top comments (0)