Expand/Collapse Widget Demo

Examples of native and custom disclosure patterns. Each widget is wrapped in an “example” container, and controlled content uses a “details” class.

Native Details Element

Built-in browser disclosure using details/summary, with the container carrying a “details” class.

What is a details/summary?

The details and summary elements provide a native, accessible expand/collapse control. Clicking the summary toggles the visibility of the content within the details element.

  • No JavaScript required
  • Keyboard accessible and announced by screen readers
  • Can be styled with CSS

Button-Controlled Panel

A custom toggle button controls a content container with the “details” class.

Accordion (Single-Open)

A group of disclosures where only one can be open at a time. Each content panel uses the “details” class.