Component Porchlight CSS

Accordion

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

52 components 51 stable 1 experimental

Command

Search Porchlight

Accordion

The .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="c-accordion">
  <details class="c-accordion__item">
    <summary class="c-accordion__header">
      <span>Section title</span>
      <svg class="c-accordion__icon">...</svg>
    </summary>
    <div class="c-accordion__panel">
      <div class="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

SelectorRole
.c-accordionContainer for items.
.c-accordion__itemA <details> element.
.c-accordion__headerThe <summary> (click target).
.c-accordion__iconChevron icon (rotates on open).
.c-accordion__panelAnimated wrapper (grid/auto-height).
.c-accordion__contentInner content (padding + overflow).