Expand/Collapse Widgets

Examples include a native details element, a custom disclosure button, and a simple accordion. Each widget is wrapped with an element using the "example" class, and each controlled content container uses the "details" class.

Native Details Element

Overview: What is an expand/collapse?

An expand/collapse widget reveals supplemental content on demand. The native details element provides built‑in accessibility, keyboard support, and progressive enhancement.

Use summary as the control, and details as the collapsible container.

This uses the HTML details/summary element with a container class of "details".

Custom Disclosure Button

A button controls a "details" container via aria-controls.

Accordion (One Panel Open)

Buttons toggle "details" panels. Only one panel is open at a time.