Expand/Collapse Widget Demo

Two accessible expand/collapse patterns are shown below: a native <details> disclosure and a custom button that controls a content region.

Example 1: Native disclosure (<details>)

What information is included?

This section expands and collapses using the browser’s native disclosure element, which supports keyboard interaction by default.

  • Keyboard: Tab to the summary, then press Enter or Space to toggle.
  • State is conveyed automatically (expanded/collapsed).
  • Content is only visible when expanded.

Example 2: Button controlling a region

Keyboard: Tab to the button, then press Enter or Space to toggle.