Expand/Collapse Widgets

Examples of native and custom disclosure controls. Each widget is contained in a div with the class “example”, and the controlled content is inside an element with the class “details”.

Native details disclosure

What is an expand/collapse widget?

An expand/collapse widget lets users reveal or hide additional content on demand, reducing visual clutter. The native HTML element <details> provides this behavior out of the box with accessible keyboard support.

  • Click the summary to toggle visibility.
  • Use the keyboard to focus and activate the summary.
  • The content below is part of the same container with class details.
<details class="details">
  <summary>Heading</summary>
  Content that can be expanded/collapsed
</details>

Custom button-controlled disclosure

Multiple sections (accordion-like)