Expand/Collapse Widget Examples

Three styles of expand/collapse widgets. Each widget is wrapped in a container with the class example, and every controlled content container uses the class details.

Example 1 — Native Details/Summary

What is an expand/collapse widget?

An expand/collapse widget lets users reveal additional information on demand. The native <details> element provides this behavior without extra JavaScript and is accessible by default.

  • Click or press Enter/Space on the summary to toggle.
  • The content below is the controlled section inside the details container.

Example 2 — Button Controlled Panel

Example 3 — Accordion (Single-Open)