Accordion

The accordion module adds smooth height animation and an animated icon to the native <details> element. No JavaScript: the browser already knows how to open and close it.

Description

An accordion is a group of native <details> elements inside a <div class="accordion">. Each item is a <summary> with the title in an <h5> inside it, plus an empty <span></span> for the rotating icon and a <div class="content"> wrapper. The wrapper lets the panel animate height and opacity together, so opening feels smooth instead of a jump.

Two behaviours decide the component: with a shared name on the <details> elements only one panel stays open at a time (native exclusive accordions), without name every panel opens and closes independently. Add the open attribute to any item to start it pre-opened, in both modes.

Zero JavaScript: the exclusive behaviour comes from the native name attribute of <details>, and the browser provides open state, keyboard and screen-reader support. The open attribute works without any styling too, so the content is visible even before CSS loads.

Animation speed comes from $transition-slow in _config.scss, and the icon color follows $color-text. Style each <details> as a card for Bootstrap-like stacked groups, or leave them bare for a minimal list. The .content wrapper pattern (height + opacity transition with allow-discrete and @starting-style) is what makes the fade smooth: reuse it anywhere you disclose content.

Independent panels

Every <details> opens and closes on its own: no shared name, no exclusivity. This is the right mode for content readers may want to compare side by side, like shipping and returns policies.

Shipping

Free shipping on orders over 50 €.

Returns

You have 30 days to return any item.

HTML
<div class="accordion">
  <details>
    <summary><h5>Shipping</h5><span></span></summary>
    <div class="content">
      <p>Free shipping on orders over 50 €.</p>
    </div>
  </details>
  <details>
    <summary><h5>Returns</h5><span></span></summary>
    <div class="content">
      <p>You have 30 days to return any item.</p>
    </div>
  </details>
</div>

Exclusive panels

A shared name turns the group into a native exclusive accordion: opening one panel closes the previous one. The open attribute marks the first item as pre-opened, and the same attribute works in both modes.

First panel

This panel starts open. Opening another one closes it automatically.

Second panel

Only one panel of the group stays open at a time.

HTML
<div class="accordion">
  <details name="faq" open>
    <summary><h5>First panel</h5><span></span></summary>
    <div class="content">
      <p>This panel starts open. Opening another one closes it automatically.</p>
    </div>
  </details>
  <details name="faq">
    <summary><h5>Second panel</h5><span></span></summary>
    <div class="content">
      <p>Only one panel of the group stays open at a time.</p>
    </div>
  </details>
</div>