How to build an accessible Collapsible in React

Built on a native <details>/<summary>, so the button role, the expanded state, and Enter/Space activation come from the platform rather than from ARIA, and the content renders before any JavaScript runs; the region is labelled by the trigger so screen readers announce the disclosure target

When to use a Collapsible

When not to use it

Keyboard interactions

Role button, verified at WCAG 2.2-AA.

Common mistakes

Avoid: Stacking many Collapsibles to emulate an accordion

Prefer: Use Accordion when sections are a related set

Accordion manages single/multiple-open semantics and shared keyboard navigation

Example

<Collapsible trigger="Show details">
  <p>Hidden content revealed on toggle.</p>
</Collapsible>

See the full Collapsible reference →