Expand/Collapse Widgets

Three common patterns for disclosure: native details, a button-controlled region, and a simple accordion. Each example is wrapped with a div that has an example class, and the container for controlled content has a details class.

Example 1: Native HTML details

More about this component

The native <details> element provides built-in expand/collapse functionality with keyboard and mouse support.

  • Click or press Space/Enter on the summary to toggle.
  • It exposes the open property and attribute.
  • You can fully style the summary and the content area.

Example 2: Button-controlled disclosure

Example 3: Simple accordion