Expand/Collapse Widgets

Examples of native and custom expand/collapse widgets. Each widget is wrapped with a div.example and the controlled content uses the details class.

Native details/summary (collapsed by default)

More information

This uses the native HTML details/summary element. It is collapsed by default and expands when you click the summary.

  • No JavaScript required
  • Accessible by default
  • Works across modern browsers

Native details/summary (expanded by default)

Release notes

This panel starts expanded using the open attribute.

  1. Improved performance
  2. Fixed accessibility issues
  3. Added new customization options

Custom toggle button controlling a content panel

Accordion (only one section open at a time)

Hint: This accordion example enforces a single open panel within this widget.