Expand/Collapse Widgets

Three approaches: native details/summary, a custom toggle, and a single-open accordion. Each widget is wrapped in a container with class "example", and the controlled content container uses class "details".

Native details/summary

What is an expand/collapse widget?

An expand/collapse widget lets users reveal or hide additional information on demand. The native HTML details/summary element provides built-in accessibility and keyboard support.

Use this when you want to keep pages concise while allowing deeper dives into specific topics.

Why use the native element?

It requires no JavaScript, is accessible out-of-the-box, and respects user expectations for disclosure controls.

Custom toggle with button

Press to expand or collapse the explanation.

Accordion (single section open)