Expand/Collapse Widgets

Three approaches: native details, button-controlled region, and a card-style toggle.

Native details element

What is an expand/collapse widget?

An expand/collapse widget reveals additional content on demand. Using the HTML <details> element provides built-in accessibility and keyboard support.

  • Click the summary to toggle the content.
  • Press Space or Enter when focused to toggle.
  • The open state can be styled via details[open].

Button-controlled region

Card-style toggle

Tip: Use the Tab key to focus each toggle and press Enter or Space to activate.