Expand/Collapse Widgets

Three approaches: native details/summary, a button controlling a region, and a CSS-only checkbox. Each widget’s controlled content is inside a container with the “details” class.

Native details/summary

What is an expand/collapse widget? Click to reveal more

An expand/collapse widget lets users show or hide additional content on demand. The native HTML details/summary element provides built-in behavior and accessibility.

  • Keyboard-accessible by default
  • No JavaScript required
  • Works across modern browsers

Button controls a region

CSS-only checkbox

No JavaScript required: the checkbox’s checked state controls the content via CSS selectors.

This technique can be useful for simple interactions but may have accessibility trade-offs compared to buttons.