Component
Accordion
Collapsible disclosure using native details/summary with auto-height animation.
On this page
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">
<!-- Streamlined modern markup (::details-content in Chrome 131+) -->
<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__content">Content goes here.</div>
</details>
<!-- Legacy wrapper structure (works in all browsers via grid fallback) -->
<details class="pl-c-accordion__item">
<summary class="pl-c-accordion__header">
<span>Section with panel wrapper</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
Three techniques are layered progressively:
- Native
::details-content(Chrome 131+, Safari 18.4+): The browser targets the disclosure box directly withblock-size: 0 to autoandinterpolate-size: allow-keywords. The.pl-c-accordion__panelwrapper is completely optional. interpolate-sizewith panel wrapper: For browsers that support keyword interpolation without::details-content, the panel wrapper animatesblock-sizedirectly.- Universal fallback:
grid-template-rows: 0fr to 1fron the panel wrapper. Works across all legacy browsers.
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 |
Optional animated wrapper (fallback for older browsers). |
.pl-c-accordion__content |
Inner content (padding + typography). |