Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.53 KB

File metadata and controls

32 lines (24 loc) · 1.53 KB
category accordion
category_description Collapsible sections implemented as accordions.

Overview

Accordions hide or reveal sections of content. Use buttons with aria-expanded and link them to regions via aria-controls; support keyboard toggling.

Relevant WCAG 2.1 success criteria

Technical guidance

  • Use a button for each accordion header; set aria-expanded to reflect state and aria-controls to point to the panel.
  • Give panels role="region" and aria-labelledby pointing back to the header.
  • Toggle hidden or CSS classes to show/hide panels when the header is activated; maintain focus on the header.
  • Support keyboard: Enter/Space toggles; Up/Down arrows move between headers; Home/End jump to first/last header.

Code example

Accordion example

<button aria-expanded="false" aria-controls="panelA" id="accA">Section A</button>
<div id="panelA" role="region" aria-labelledby="accA" hidden>
  <p>Panel A content.</p>
</div>