---
title: "Accordion"
description: "Accordion component - collapsible sections using <details>/<summary>."
slug: "accordion"
---

import { DocPage, PageHeader, SkillPanel, Example, ExampleLabel, ExampleHint, ExampleCode, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeCard, TableCard, ApiSection } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="accordion" title="Accordion" component="accordion">
  Collapsible content sections built on native <code>&lt;details&gt;</code> / <code>&lt;summary&gt;</code>. Multi-open needs zero JS. Single-open adds a small toggle handler.
</PageHeader>

<SkillPanel component="accordion">
  <SkillField label="Native basis">
<SkillText><code>&lt;details&gt;</code> / <code>&lt;summary&gt;</code> elements. The browser provides:</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details" title="native disclosure widget with built-in open/close state"><code>&lt;details&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary" title="clickable heading that toggles the parent `<details>`"><code>&lt;summary&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/::details-content" title="pseudo-element for styling and animating the collapsible content"><code>::details-content</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement/toggle_event" title="fires when the `open` state changes"><code>toggle event</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style" title="defines entry animation starting values for open transition"><code>@starting-style</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.accordion</code>
    <code>.accordion-item</code>
    <code>.accordion-trigger</code>
    <code>.accordion-chevron</code>
    <code>.accordion-content</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText dense>• <code>data-type</code></SkillText>
  <SkillText>• <code>data-collapsible</code></SkillText>
  </SkillField>

  <SkillField label="Keyboard">
<SkillGrid>
    <Variant name="Key" description="Behavior" />
    <Variant name="Tab" description="Move focus between summary elements" />
    <Variant name="Enter" description="Toggle the focused item" />
    <Variant name="Space" description="Toggle the focused item" />
  </SkillGrid>
  </SkillField>

  <SkillField label="Notes">
<SkillText dense>• <code>&lt;details&gt;/&lt;summary&gt;</code> is the most accessible accordion implementation - it works with zero JS and zero ARIA</SkillText>
  <SkillText dense>• For single-open behavior, the <code>toggle</code> event on <code>&lt;details&gt;</code> fires after the state changes</SkillText>
  <SkillText dense>• The <code>open</code> attribute is the source of truth for whether an item is expanded</SkillText>
  <SkillText dense>• Avoid nesting accordions - use a flat list with clear headings instead</SkillText>
  <SkillText dense>• A non-collapsible single accordion never closes its last open item - the attempt is denied in the cancellable <code>beforetoggle</code> event (<code>preventDefault()</code>), so the click is a silent no-op; reopening in <code>toggle</code> would flicker</SkillText>
  <SkillText dense>• The chevron rotation relies on <code>details\[open\] &gt;</code> selector - this is pure CSS</SkillText>
  <SkillText dense>• Content height animation uses <code>::details-content</code> pseudo-element with <code>block-size</code> transition and <code>@starting-style</code> for the enter animation - fully CSS-only, no JS measurement needed</SkillText>
  <SkillText dense>• Set <code>data-type="single"</code> for accordion behavior (only one open); omit for disclosure list (any number open)</SkillText>
  <p class="text-muted-foreground m-0">• Set <code>data-collapsible</code> alongside <code>data-type="single"</code> to allow all items to be closed</p>
  </SkillField>
</SkillPanel>

```html example label="Multi-open" hint="Default behavior - multiple items can be open simultaneously. Uses native &lt;details&gt;/&lt;summary&gt; with zero JavaScript." height="20"
<div class="accordion" style="max-width: 28rem; width: 100%">
  <details class="accordion-item" open>
    <summary class="accordion-trigger">
      <span>Is it accessible?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p
        >Yes. It uses native HTML details/summary elements which are fully accessible by default. Screen reader and
        keyboard support are built in.</p
      >
    </div>
  </details>
  <details class="accordion-item" open>
    <summary class="accordion-trigger">
      <span>Is it styled?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p>Yes. It follows the shadcn/ui token system for consistent theming across light and dark modes.</p>
    </div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger">
      <span>Is it animated?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p
        >Yes. Uses <code>::details-content</code> with <code>calc-size(auto, size)</code> for smooth height animation.
        The chevron rotates via CSS transition.</p
      >
    </div>
  </details>
</div>
```

```html example label="Single-open" hint="Only one item can be open at a time. Add data-type='single' to the wrapper - a small JS handler closes siblings on toggle." height="20"
<div class="accordion" data-type="single" style="max-width: 28rem; width: 100%">
  <details class="accordion-item" open>
    <summary class="accordion-trigger">
      <span>What payment methods do you accept?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p>We accept all major credit cards (Visa, Mastercard, AmEx), PayPal, and bank transfers for annual plans.</p>
    </div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger">
      <span>Can I cancel my subscription?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p
        >Yes, you can cancel at any time from your account settings. Your access continues until the end of the current
        billing period.</p
      >
    </div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger">
      <span>Do you offer team pricing?</span>
      <svg
        class="accordion-chevron"
        aria-hidden="true"
        width="16"
        height="16"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
      >
        <path d="m6 9 6 6 6-6"></path>
      </svg>
    </summary>
    <div class="accordion-content">
      <p
        >Yes. Teams of 5 or more get a 20% discount. Contact our sales team for custom enterprise plans with dedicated
        support.</p
      >
    </div>
  </details>
</div>
```

```html example label="Custom colors" hint="Set background and color on an item - its hover tint, marker and content text derive from that color." height="22"
<div class="accordion" data-variant="separated" data-marker="arrow" style="max-width: 28rem; width: 100%">
  <details
    class="accordion-item"
    open
    style="background: oklch(0.93 0.06 190); color: oklch(0.32 0.08 200); border-color: oklch(0.8 0.08 190)"
  >
    <summary class="accordion-trigger"><span>Teal</span></summary>
    <div class="accordion-content"><p>Two declarations color the whole item.</p></div>
  </details>
  <details
    class="accordion-item"
    style="background: oklch(0.95 0.07 85); color: oklch(0.4 0.09 60); border-color: oklch(0.85 0.1 80)"
  >
    <summary class="accordion-trigger"><span>Amber</span></summary>
    <div class="accordion-content"><p>Any palette works - the marker and text mix from the item color.</p></div>
  </details>
  <details
    class="accordion-item"
    style="background: linear-gradient(120deg, oklch(0.55 0.22 300), oklch(0.6 0.2 350)); color: white; border: 0"
  >
    <summary class="accordion-trigger"><span>Gradient</span></summary>
    <div class="accordion-content"><p>Even a gradient surface.</p></div>
  </details>
</div>
```

```html example label="Icons and emojis" hint="An .accordion-icon in front of each heading - an icon or an emoji in a fixed box, so the headings line up." height="22"
<div class="accordion" data-variant="separated" data-marker="arrow" style="max-width: 28rem; width: 100%">
  <details class="accordion-item" open>
    <summary class="accordion-trigger"
      ><span class="accordion-icon" aria-hidden="true"><i data-lucide="shield-check"></i></span
      ><span>Security</span></summary
    >
    <div class="accordion-content"><p>Two-factor authentication and sessions.</p></div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger"
      ><span class="accordion-icon" aria-hidden="true"><i data-lucide="credit-card"></i></span
      ><span>Billing</span></summary
    >
    <div class="accordion-content"><p>Plan, invoices and payment methods.</p></div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger"
      ><span class="accordion-icon" aria-hidden="true">🎨</span><span>Appearance</span></summary
    >
    <div class="accordion-content"><p>Theme, density and fonts.</p></div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger"
      ><span class="accordion-icon" aria-hidden="true">🔔</span><span>Notifications</span></summary
    >
    <div class="accordion-content"><p>Email, push and in-app.</p></div>
  </details>
</div>
```

```html example label="Custom open/close signs" hint="Own glyphs: the .accordion-chevron turns 180° (90° with data-turn='quarter' for a chevron-right) - or two elements, .accordion-when-closed and .accordion-when-open, swap." height="22"
<div class="accordion" data-variant="bordered" style="max-width: 28rem; width: 100%">
  <details class="accordion-item" open>
    <summary class="accordion-trigger"
      ><span>Quarter turn</span><i data-lucide="chevron-right" class="accordion-chevron" data-turn="quarter"></i
    ></summary>
    <div class="accordion-content"><p>A chevron-right that turns down when open.</p></div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger"
      ><span class="accordion-icon" aria-hidden="true"
        ><span class="accordion-when-closed">📁</span><span class="accordion-when-open">📂</span></span
      ><span>Projects</span></summary
    >
    <div class="accordion-content"><p>The folder opens with the panel.</p></div>
  </details>
  <details class="accordion-item">
    <summary class="accordion-trigger"
      ><span>Release notes</span><span class="accordion-when-closed text-sm">Show</span
      ><span class="accordion-when-open text-sm">Hide</span></summary
    >
    <div class="accordion-content"><p>Words instead of an icon.</p></div>
  </details>
</div>
```

```html example label="Right to left" hint="Logical throughout: in dir='rtl' the icon leads on the right, the marker sits on the left." height="22"
<div dir="rtl" lang="ar" style="width: 100%; max-width: 28rem">
  <div class="accordion" data-variant="separated" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"
        ><span class="accordion-icon" aria-hidden="true"><i data-lucide="shield-check"></i></span
        ><span>الأمان</span></summary
      >
      <div class="accordion-content"><p>المصادقة الثنائية والجلسات النشطة.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"
        ><span class="accordion-icon" aria-hidden="true">🎨</span><span>المظهر</span></summary
      >
      <div class="accordion-content"><p>السمة والكثافة والخطوط.</p></div>
    </details>
  </div>
</div>
```

```html example label="Surfaces" hint="data-variant on the .accordion: bordered (one box), separated (a card per item), ghost (no dividers). Boxed variants inset the text and tint the row on hover." height="30"
<div class="grid gap-6" style="grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); width: 100%">
  <div class="accordion" data-variant="bordered" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-variant="separated" data-marker="plus" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-variant="ghost" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
</div>
```

```html example label="Colors" hint="muted, primary and neutral put every item on that surface; highlight keeps items plain and turns the open one primary. Heading, marker and content follow the surface's text color." height="40"
<div class="grid gap-6" style="grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); width: 100%">
  <div class="accordion" data-variant="muted" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-variant="primary" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-variant="neutral" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-variant="highlight" data-marker="plus" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
</div>
```

```html example label="Bold headings" hint="data-size scales every heading: sm, md (default), lg semibold, xl bold." height="28"
<div class="stack gap-6" style="width: 100%; max-width: 28rem">
  <div class="accordion" data-size="lg" data-marker="arrow" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
  </div>
  <div class="accordion" data-size="xl" data-variant="bordered" data-marker="arrow" style="width: 100%">
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
  </div>
</div>
```

```html example label="Arrow and plus markers" hint="data-marker='arrow' / 'plus' on the .accordion draws the sign for every item - no icon markup; data-marker-position='start' puts it before the heading (a FAQ, a file tree)." height="26"
<div class="grid gap-6" style="grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); width: 100%">
  <div class="accordion" data-marker="plus" data-marker-position="start" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
  <div class="accordion" data-marker="arrow" data-marker-position="start" data-variant="bordered" style="width: 100%">
    <details class="accordion-item" open>
      <summary class="accordion-trigger"><span>Is it accessible?</span></summary>
      <div class="accordion-content"
        ><p>Yes - native details/summary: keyboard and screen readers work out of the box.</p></div
      >
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Is it styled?</span></summary>
      <div class="accordion-content"><p>It follows your theme tokens - every variant below is one attribute.</p></div>
    </details>
    <details class="accordion-item">
      <summary class="accordion-trigger"><span>Does it need JavaScript?</span></summary>
      <div class="accordion-content"
        ><p>No. Only data-type="single" adds a small handler that closes the siblings.</p></div
      >
    </details>
  </div>
</div>
```

```html example label="Density" hint="Set data-density on the component root to scale its internal whitespace. A whitespace policy, not a zoom: only gaps and padding scale (ratio 0.75 / 1 / 1.25), typography and fixed dimensions stay identical. comfortable matches the unsized default." height="20"
<div class="flex flex-wrap gap-4">
  <div class="flex-1 min-w-48">
    <p class="demo-label">Compact</p>
    <div class="accordion" data-density="compact"
      ><details class="accordion-item" open
        ><summary class="accordion-trigger"
          ><span>Section compact</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Trigger and panel padding scale with the density.</p></div></details
      ><details class="accordion-item"
        ><summary class="accordion-trigger"
          ><span>Second section</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Closed until opened.</p></div></details
      ></div
    >
  </div>
  <div class="flex-1 min-w-48">
    <p class="demo-label">Comfortable</p>
    <div class="accordion" data-density="comfortable"
      ><details class="accordion-item" open
        ><summary class="accordion-trigger"
          ><span>Section comfortable</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Trigger and panel padding scale with the density.</p></div></details
      ><details class="accordion-item"
        ><summary class="accordion-trigger"
          ><span>Second section</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Closed until opened.</p></div></details
      ></div
    >
  </div>
  <div class="flex-1 min-w-48">
    <p class="demo-label">Spacious</p>
    <div class="accordion" data-density="spacious"
      ><details class="accordion-item" open
        ><summary class="accordion-trigger"
          ><span>Section spacious</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Trigger and panel padding scale with the density.</p></div></details
      ><details class="accordion-item"
        ><summary class="accordion-trigger"
          ><span>Second section</span
          ><svg
            class="accordion-chevron"
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
          >
            <path d="m6 9 6 6 6-6"></path></svg></summary
        ><div class="accordion-content"><p>Closed until opened.</p></div></details
      ></div
    >
  </div>
</div>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">Named states via the shared State API, driven per instance through the bound <code>api</code>:</p>
  <ul class="text-sm text-muted-foreground m-0 mb-3 ps-5">
    <li><code>default</code> - the authored markup, snapshotted when the component initializes</li>
    <li><code>all-open</code> - every <code>&lt;details&gt;</code> item expanded (single-open enforcement suspended)</li>
    <li><code>all-closed</code> - every item collapsed, even without <code>data-collapsible</code></li>
  </ul>
  <p class="text-sm text-muted-foreground">The single-open demo carries <code>data-state-demo</code>; <code>bun run screenshots</code> drives it via <code>el.api.setState(name)</code> and captures <code>screenshots/\{mode\}/accordion-\{state\}.png</code>.</p>

Machine contract - verified against <a class="link" href="../schemas/accordion.schema.json"><code>accordion.schema.json</code></a> by <code>bun run verify</code>:

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `all-open` | `boolean` | `true`, `false` | `false` | Every `.accordion-item` opened in one batch. |
| `all-closed` | `boolean` | `true`, `false` | `false` | Every `.accordion-item` closed in one batch. |
```

</StatesSection>

<ApiSection component="accordion" />

<SourceFiles component="accordion" section="css" />

<SourceFiles component="accordion" section="js">
  <SourceNote for="js">Only needed for single-open mode (when <code>data-type="single"</code> is set). Multi-open accordions use zero JavaScript - native <code>&lt;details&gt;</code> handles everything.</SourceNote>
</SourceFiles>

</DocPage>
