ARIA for Accordion Components
You'll learn how to use ARIA attributes to make accordion triggers and panels properly understandable to screen readers.
What Makes an Accordion Accessible?
An accordion's expand/collapse buttons need to communicate their current state and relationship to the content they control. Without ARIA, a screen reader user might not realize a button is expandable or which panel it affects.
The Three Essential ARIA Attributes
aria-expanded
This tells assistive technologies whether the accordion panel is currently visible or hidden. Set it to "true" when open and "false" when closed:
<button aria-expanded="false">
What are your hours?
</button>
When the user clicks, update it to "true" and the screen reader will announce "expanded."
aria-controls
This creates a programmatic relationship between the button and the panel it controls. Set its value to the id of the associated panel:
<button
aria-expanded="false"
aria-controls="panel-hours">
What are your hours?
</button>
<div id="panel-hours">
We're open 9am-5pm Monday through Friday.
</div>
Proper Button Role
Always use an actual <button> element (not a <div> or <span>). Buttons are naturally keyboard-accessible and convey the correct role to screen readers.
Think of It Like a Label
Just as a light switch has markings showing "on" and "off," aria-expanded labels the current state. And like a label on a thermostat pointing to "controls basement temperature," aria-controls points to what the button affects.
Key Takeaway: Use aria-expanded to announce state, aria-controls to link triggers with panels, and always use semantic <button> elements for accordion triggers.