Components
Accordion
Vertically collapsing panels built on native exclusive details groups — no script, no .collapsed class.
How it works
Each panel is a <details class="accordion-item">. The
<summary class="accordion-button"> is the header and the trigger; the
.accordion-body follows it. Giving every panel the same name attribute makes the
group exclusive — opening one closes the others — because that is how <details name>
behaves natively.
- Baseline:
<details>/<summary>; exclusive groups vianame(Chrome 120, Safari 17.2, Firefox 130). Older engines ignorenameand simply allow several panels open. - Enhancement: the open and close animate through
::details-contentandinterpolate-size. Without them the panel snaps open. - Fallback: none needed. There is no
.collapsedclass to manage; the chevron and the active background follow the[open]attribute.
.accordion-header / .accordion-collapse wrappers are not required. If you
want a heading in the document outline, put it inside the summary — see
Headings.Example
Click a header to expand it. The first panel is open on load through the open attribute.
Accordion item #1
<details> carries the open attribute. Use any HTML inside; padding comes
from .accordion-body. Opening another panel in this group closes this one.
Accordion item #2
name, so it swaps with its
neighbours. The 1985 Wrestle-Rama card ran four hours and nobody asked for an intermission.
Accordion item #3
HTML
<div class="accordion">
<details class="accordion-item" name="accordion-example" open>
<summary class="accordion-button">Accordion item #1</summary>
<div class="accordion-body">
<strong>This is the first item's accordion body.</strong> It is shown by default because the
<code><details></code> carries the <code>open</code> attribute. Use any HTML inside; padding comes
from <code>.accordion-body</code>. Opening another panel in this group closes this one.
</div>
</details>
<details class="accordion-item" name="accordion-example">
<summary class="accordion-button">Accordion item #2</summary>
<div class="accordion-body">
<strong>This is the second item's accordion body.</strong> Same <code>name</code>, so it swaps with its
neighbours. The 1985 Wrestle-Rama card ran four hours and nobody asked for an intermission.
</div>
</details>
<details class="accordion-item" name="accordion-example">
<summary class="accordion-button">Accordion item #3</summary>
<div class="accordion-body">
<strong>This is the third item's accordion body.</strong> Keyboard users press Enter or Space on the
header; screen readers announce it as a disclosure button with its expanded state.
</div>
</details>
</div>Flush
Add .accordion-flush to remove the outer border and rounded corners, so the accordion sits edge to
edge inside its parent.
Accordion item #1
Accordion item #2
Accordion item #3
HTML
<div class="accordion accordion-flush">
<details class="accordion-item" name="accordion-flush">
<summary class="accordion-button">Accordion item #1</summary>
<div class="accordion-body">Placeholder content for this accordion. It is flush against the container, with no border on the left or right.</div>
</details>
<details class="accordion-item" name="accordion-flush">
<summary class="accordion-button">Accordion item #2</summary>
<div class="accordion-body">Placeholder content for the second item.</div>
</details>
<details class="accordion-item" name="accordion-flush">
<summary class="accordion-button">Accordion item #3</summary>
<div class="accordion-body">Placeholder content for the third item.</div>
</details>
</div>Always open
Leave the name attribute off and the panels become independent — any number can stay open at
once. This replaces Bootstrap's data-bs-parent omission.
Accordion item #1
name, so opening #2 leaves this one open.Accordion item #2
Accordion item #3
HTML
<div class="accordion">
<details class="accordion-item" open>
<summary class="accordion-button">Accordion item #1</summary>
<div class="accordion-body"><strong>This is the first item's accordion body.</strong> No <code>name</code>, so opening #2 leaves this one open.</div>
</details>
<details class="accordion-item" open>
<summary class="accordion-button">Accordion item #2</summary>
<div class="accordion-body"><strong>This is the second item's accordion body.</strong> Also open on load.</div>
</details>
<details class="accordion-item">
<summary class="accordion-button">Accordion item #3</summary>
<div class="accordion-body"><strong>This is the third item's accordion body.</strong> Closed until you click it.</div>
</details>
</div>Headings
To keep a proper outline (an FAQ, a results archive by year), nest a heading inside the summary with
.accordion-header. The theme resets its font and margin so it inherits the button styling.
1987 — Clash at the Coliseum
1994 — Steel Cage Summer
2002 — Last Call
HTML
<div class="accordion">
<details class="accordion-item" name="accordion-headings" open>
<summary class="accordion-button"><h2 class="accordion-header">1987 — Clash at the Coliseum</h2></summary>
<div class="accordion-body">Main event: a two-out-of-three-falls title match. The third fall went twenty-two minutes.</div>
</details>
<details class="accordion-item" name="accordion-headings">
<summary class="accordion-button"><h2 class="accordion-header">1994 — Steel Cage Summer</h2></summary>
<div class="accordion-body">The cage match that cost the champion the belt — and the rematch nobody saw coming.</div>
</details>
<details class="accordion-item" name="accordion-headings">
<summary class="accordion-button"><h2 class="accordion-header">2002 — Last Call</h2></summary>
<div class="accordion-body">The final show of the territory era. Doors closed at midnight.</div>
</details>
</div>Accessibility
- The
<summary>is a native disclosure button: focusable, activated by Enter and Space, and announced witharia-expandedsemantics without extra attributes. - Do not add
role="button"oraria-controls; the element already carries them implicitly. - Engines that support fragment navigation into a closed
<details>open it automatically, so deep links into an accordion keep working. - The height animation is disabled under
prefers-reduced-motion: reduce.
CSS
All of Bootstrap's --bs-accordion-* variables apply. The theme sets the active header to the
gold subtle background (#f3e8c3) with navy text in light mode, and to the dark subtle gold with
gold-300 text in dark mode. The chevron is navy in light mode.
.accordion {
--bs-accordion-border-radius: var(--bs-border-radius); // 6px
--bs-accordion-btn-padding-x: 1.25rem;
--bs-accordion-btn-padding-y: 1rem;
--bs-accordion-active-color: #0a1b3d; // navy-900
--bs-accordion-active-bg: #f3e8c3; // primary-bg-subtle
}
State is driven by the attribute, not by a class:
.accordion-item:not([open]) > .accordion-button // closed look (what Bootstrap called .collapsed)
.accordion-item[open] > .accordion-button // active look, rotated chevron
.accordion-item::details-content // animated height (progressive)
.accordion-flush > .accordion-item // square corners
.accordion-button > .accordion-header // heading inside the summary
The relevant Sass variables are $accordion-button-active-color,
$accordion-button-active-bg and $accordion-icon-active-color in
scss/_variables.scss. See Sass.