Expand / Collapse Widget — Accessible Examples

Two accessible expand/collapse widgets. Each widget is wrapped in a container with class "example" and the controlled content container uses class "details". Use keyboard: Tab to the button, then Space or Enter to toggle. Press Escape while focus is inside the panel to close it.

Basic expandable panel

This simple panel uses a button with aria-expanded and aria-controls. The pane has class "details".

Expandable panel with more controls

This example demonstrates restoring focusability of interactive elements inside the details region when it opens.