Expand/Collapse Widgets

Three examples: a native details element, a button-controlled panel, and a single-select accordion. Each widget is wrapped with an "example" container, and the controlled content uses the "details" class.

Native Details Element

What is an expand/collapse widget?

An expand/collapse widget lets users reveal additional content on demand. The native HTML details element provides this behavior with built-in accessibility and keyboard support.

Tip: The triangle indicator rotates when expanded. This example uses the

element and a styled summary.

  • Built-in keyboard support
  • Declarative open/closed state
  • Accessible by default

Button-Controlled Panel

Accordion (Single-Select)