Expand/Collapse Widget Demonstration

Native details/summary

What is an expand/collapse widget?

An expand/collapse widget shows or hides content on demand. This is a native HTML implementation using the details and summary elements.

  • Keyboard accessible by default
  • No custom JavaScript required

Native details, initially open

Click to collapse

This section starts expanded using the open attribute.

Click the summary to toggle collapse.

Custom button controlling content

Multiple controlled sections

Panel A starts expanded.

Click the button to collapse or expand this panel.