Expand/Collapse Widget Demonstration

This page shows three approaches: a native HTML details/summary, a custom toggle button, and an accordion where only one section stays open.

Native details/summary

Built-in HTML behavior. The controlled container is the details element itself with class details.

What is an expand/collapse widget?

An expand/collapse widget hides supplemental information until a user chooses to reveal it. This helps reduce visual clutter and lets readers focus.

  • Click the header to toggle visibility.
  • Use the keyboard: Tab to the summary, then Enter or Space to toggle.
  • The element remembers its open state per page interaction.

Custom toggle button

A button controls a separate content region. The controlled container uses the details class.

Accordion (single expansion)

Only one section is expanded at a time. Each controlled content container has the details class.