Expand / Collapse Widget Examples

A simple collapsible panel
Starts expanded

This panel starts expanded to demonstrate the expanded initial state. Scripts will measure and set a height to allow a smooth open animation if you toggle it.

  • Accessible: aria-expanded on the button
  • Accessible: aria-hidden on the details container
  • Animated: smooth transition of max-height
Nested example

Tip: The JavaScript below wires up each button to toggle its corresponding .details container using aria attributes and a smooth height transition.