Expand/Collapse Widgets

Examples showing native and custom expandable sections. Each widget is wrapped with a div.example and uses a container with a details class.

Example 1: Native details/summary

This section uses the built-in HTML <details> and <summary> elements. It requires no JavaScript and is accessible out of the box.

  • Toggle via mouse, keyboard, or touch.
  • Preserves user state across page refreshes in some browsers.
  • Can be styled to fit your design system.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse potenti. Curabitur dictum nisl sed mauris bibendum, nec aliquam augue tempor.

Example 2: Button-controlled content

Example 3: Animated expand/collapse