Expand/Collapse Widgets

Examples of native and custom expand/collapse controls. Each controlled content container uses the class details.

Native HTML details
What is an expand/collapse widget?

An expand/collapse widget lets users reveal or hide additional information on demand. The native HTML element <details> with a <summary> provides a built-in accessible option.

This example uses the details element as the container for the controlled content and adds the class details to it.

  • Click the summary to toggle the content.
  • Keyboard users can focus the summary and press Enter or Space.
Custom button toggle
Accordion (single-panel expanded)