Expand / Collapse Widget

Three examples of an accessible expand/collapse widget. Each widget is wrapped in a container with class "example". The controlled content containers use the class "details".

This example starts open. The script will initialize its height so the transition system works when it is later collapsed.

  1. Starts expanded (aria-expanded="true").
  2. Contains richer content including a short list.
  3. When collapsed, the chevron rotates and the content animates closed.

Tips: Use the Enter or Space keys to toggle when a control has focus. The chevrons rotate to indicate state and the details are animated for a smoother experience.