< Back to Standards

Accordions

VoiceOver reading 'Click to open details, expanded, button'.
VoiceOver shown focused on an accordion with the expanded state and button role spoken.

Accordions are disclosure controls used to expand and collapse (show and hide) content.

Impacted Users

Screen reader users need to hear the expanded or collapsed state of the accordion so they know when it's opened or closed.

Users with cognitive disabilities need the ability to hide content that may be cluttering the page.

Keyboard users need accordions to be keyboard focusable and operable to expand and collapse.

Designers

Annotate accordions in your designs with an expanded and collapsed state or using details summary elements.

Accordions need to be annotated with an expanded and collapsed state, e.g. adding aria-expanded=true/false or using details summary elements.

✅ Do

Good Design Example

Screenshot from the figma example.

❌ Don't

Bad Design Example

Screenshot from the figma example.

Live Figma Example

Link to Figma example

Testing for Accessibility

Design Review
  1. Look for ... in the design.
  2. Make sure ... is annotated in the design.
  3. Make sure ...
  4. If ... is properly annotated in the design then it passes. ✅
  5. If ... is not annotated in the design then it fails. ❌
  6. If ... then it passes. ✅
  7. If ... then it fails. ❌

Content Designers

Code accordions as details summary elements with meaningful details text.

Use details summary elements to create accordions because that control is keyboard and screen reader accessible by default.

✅ Do

Good Content Example

See the Pen Accordion - Good Example by Paul J. Adam (@pauljadam) on CodePen.

Live Good Content Example

Accordion - Good Example

❌ Don't

Bad Content Examples

See the Pen Accordion - Good Example by Paul J. Adam (@pauljadam) on CodePen.

Live Bad Content Example

Testing for Accessibility

Using Web Inspector
  1. Right Click > Inspect ... on the page.
  2. Make sure ...
  3. Make sure ...
  4. If ... then it passes. ✅
  5. If ... then it fails. ❌
Using Screen Reader
  1. Use the screen reader to navigate to ...
  2. Make sure ...
  3. Make sure ...
  4. If ... then it passes. ✅
  5. If ... then it fails. ❌

Developers

Code accordions as native details summary HTML elements or use aria-expanded on a button if native control can't be used.

Native details summary elements are keyboard and screen reader accessible by default. Details summary elements manage the expanded and collapsed state for screen readers without requiring any JavaScript. Don't use ARIA to create accessible accordions unless using native HTML details summary elements is not possible.

✅ Do

Good Code Example

See the Pen Custom Accordion - Bad Example by Paul J. Adam (@pauljadam) on CodePen.

Live Good Code Example

Custom Accordion - Good Example

❌ Don't

Bad Code Example

See the Pen Custom Accordion - Bad Example by Paul J. Adam (@pauljadam) on CodePen.

Live Bad Code Example

Custom Accordion - Bad Example

Testing for Accessibility

Using Web Inspector
  1. Right Click > Inspect ... on the page.
  2. Make sure ...
  3. Make sure ...
  4. If ... then it passes. ✅
  5. If ... then it fails. ❌
  6. If ... then it passes. ✅
  7. If ... then it fails. ❌
Using Screen Reader
  1. Use the screen reader to navigate to ...
  2. Make sure ...
  3. Make sure ...
  4. If ... then it passes. ✅
  5. If ... then it fails. ❌

Disabilities Affected

Assistive Technologies Applicable

Design System Documentation

Collapsible | Duet Design System

HTML Standard

The details element

ARIA Design Patterns

WCAG Success Criteria

Success Techniques for WCAG

Failure Techniques for WCAG