ComponentPorchlight CSS

Accordion

Collapsible disclosure using native details/summary with auto-height animation.

51 components9 patterns46 stable5 experimental

Command

Search Porchlight

Accordion

The .pl-c-accordion wraps <details>/<summary> elements for a collapsible disclosure UI. Animates open/close to/from height: auto using interpolate-size: allow-keywords where supported, with a universal grid-template-rows: 0fr to 1fr fallback.

Semantic HTML

<div class="pl-c-accordion">
  <details class="pl-c-accordion__item">
    <summary class="pl-c-accordion__header">
      <span>Section title</span>
      <svg class="pl-c-accordion__icon">...</svg>
    </summary>
    <div class="pl-c-accordion__panel">
      <div class="pl-c-accordion__content">Content goes here.</div>
    </div>
  </details>
</div>

Animation strategy

Two techniques are used, layered:

  1. Universal fallback: grid-template-rows: 0fr to 1fr on the panel wrapper. Works in all browsers. Smooth height transition.
  2. Enhanced: Where interpolate-size: allow-keywords is supported, block-size: 0 to auto animates directly. Produces smoother results.

Class contract

Selector Role
.pl-c-accordion Container for items.
.pl-c-accordion__item A <details> element.
.pl-c-accordion__header The <summary> (click target).
.pl-c-accordion__icon Chevron icon (rotates on open).
.pl-c-accordion__panel Animated wrapper (grid/auto-height).
.pl-c-accordion__content Inner content (padding + overflow).