Expand/Collapse Widgets

This page demonstrates several expand/collapse widgets. Each widget is wrapped in a div with the class "example", and each controlled content container uses the "details" class.

Example 1: Native details/summary

Uses the built-in HTML <details> element with a <summary> for accessible expand/collapse behavior.

Click to expand native details

This content is inside a native details element. It is accessible and requires no JavaScript to expand or collapse.

  • It supports keyboard and screen readers out of the box.
  • The disclosure arrow rotates to indicate open/closed state.
  • You can nest content, such as lists and links.

Example 2: Button-controlled panel

A button with aria-expanded toggles a region identified by aria-controls.

Project Notes

Example 3: Multi-section accordion

Only one section stays open at a time within this accordion.

What is an accordion?
Why use accordions?
Accessibility considerations