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.
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.
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 disclosure uses a button that toggles the visibility of a content region. The button announces its state via aria-expanded and references the controlled region via aria-controls.
The region is hidden and shown by toggling the hidden attribute.
An accordion is a set of panels where activating a header reveals content while optionally collapsing others.
Use accordions to reduce page clutter and organize dense sections. Keep titles short, descriptive, and scannable.
Provide clear focus styles, ensure buttons are real buttons (not divs), and update aria-expanded to reflect current state.