Expand/Collapse Widgets

Examples of expandable panels using the native details element and a custom ARIA-controlled toggle.

Native widget using the details element

How does this work?

The native <details> element provides built-in expand/collapse behavior with keyboard and mouse support. The content below the summary is revealed when open.

  • It toggles without JavaScript.
  • It is accessible by default in most modern browsers.
  • You can enhance styles while keeping semantics.

Custom button-controlled panel

Press to reveal content

Accordion (group of expand/collapse items)

Only one section open at a time (optional behavior).