Tailwind Accordion: 16 Examples, From Details to ARIA

Long FAQ answers push everything else down the page, and most visitors only want one of them. A Tailwind accordion keeps each answer closed until someone opens it, and the native build needs no JavaScript.

Below are 16 Tailwind accordion examples you can copy, followed by a guide to details and summary, height animation, ARIA wiring and library options.

By Bogdan Sandu ยท Updated October 29, 2026

Every example is built with Tailwind CSS v4.3 utility classes. To try one quickly, add the Play CDN tags below to your page and paste the example's HTML, CSS and JS. The dark variant line makes dark: classes follow a .dark class instead of the system setting. For production, install Tailwind with Vite or the CLI.

<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<style type="text/tailwindcss">
  @custom-variant dark (&:where(.dark, .dark *));
</style>

Native details and summary accordions

Every demo in this group is a details element with a summary. The browser keeps the open state and handles Enter and Space, and Tailwind styles that state with open:, group-open: and the details-content: variant.

FAQ card with rotating chevron

  • details
  • group-open:rotate-180
  • list-none
  • divide-y

Click a question to open it.

Each item is a details element marked group, so the chevron can rotate with group-open:rotate-180 and the question can change color with group-open:text-indigo-700. list-none and the [&::-webkit-details-marker]:hidden arbitrary variant remove the default triangle in every engine, and divide-y draws the separators. No CSS and no JavaScript.

View code
<div class="w-full max-w-lg rounded-2xl border border-slate-200 bg-white shadow-sm">
  <div class="px-5 pt-5 pb-3">
    <h2 class="text-lg font-semibold tracking-tight text-slate-900">Frequently asked questions</h2>
    <p class="mt-1 text-sm text-slate-600">Fieldnote syncs your notes across phone, tablet and laptop.</p>
  </div>
  <div class="divide-y divide-slate-200 border-t border-slate-200">
    <details class="group" open>
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 px-5 py-3 text-left font-medium text-slate-900 hover:bg-slate-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-600 group-open:text-indigo-700 [&::-webkit-details-marker]:hidden">
        <span>Does Fieldnote work offline?</span>
        <svg class="size-5 shrink-0 text-slate-400 group-open:rotate-180 group-open:text-indigo-600 motion-safe:transition-transform motion-safe:duration-200" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-slate-600">Yes. Notes are stored on the device first and sync the next time you are online. Edits made on two devices at once are merged line by line.</p>
    </details>
    <details class="group">
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 px-5 py-3 text-left font-medium text-slate-900 hover:bg-slate-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-600 group-open:text-indigo-700 [&::-webkit-details-marker]:hidden">
        <span>Can I import notes from another app?</span>
        <svg class="size-5 shrink-0 text-slate-400 group-open:rotate-180 group-open:text-indigo-600 motion-safe:transition-transform motion-safe:duration-200" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-slate-600">Drop a folder of Markdown or plain text files on the import screen. Folder names become notebooks and the file dates are kept.</p>
    </details>
    <details class="group">
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 px-5 py-3 text-left font-medium text-slate-900 hover:bg-slate-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-600 group-open:text-indigo-700 [&::-webkit-details-marker]:hidden">
        <span>Who can read my shared notebooks?</span>
        <svg class="size-5 shrink-0 text-slate-400 group-open:rotate-180 group-open:text-indigo-600 motion-safe:transition-transform motion-safe:duration-200" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-slate-600">Only the people you invite by email. A shared link can be set to view only, and you can revoke it at any time from the notebook menu.</p>
    </details>
    <details class="group">
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 rounded-b-2xl px-5 py-3 text-left font-medium text-slate-900 hover:bg-slate-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-600 group-open:rounded-none group-open:text-indigo-700 [&::-webkit-details-marker]:hidden">
        <span>How do I cancel my subscription?</span>
        <svg class="size-5 shrink-0 text-slate-400 group-open:rotate-180 group-open:text-indigo-600 motion-safe:transition-transform motion-safe:duration-200" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-slate-600">Open Settings, then Billing, then Cancel plan. You keep Pro features until the end of the period you paid for.</p>
    </details>
  </div>
</div>

One at a time with the name attribute

  • details name=""
  • open:border-*
  • open:shadow-md
  • group-open:

Click a question to open it.

All four details share name="tac-ship", so the browser closes the open item when another one opens: an exclusive accordion with no JavaScript. The open: variant styles the details element itself (border, background, shadow) while group-open: reaches the icon inside. Browsers without exclusive details simply let several stay open.

View code
<div class="w-full max-w-lg">
  <h2 class="text-lg font-semibold tracking-tight text-stone-900">Shipping and returns</h2>
  <p class="mt-1 text-sm text-stone-600">Kiln and Co ships hand-thrown stoneware from Porto.</p>
  <div class="mt-4 space-y-2">
    <details name="tac-ship" class="group rounded-xl border border-stone-200 bg-white open:border-emerald-600 open:bg-emerald-50/60 open:shadow-md" open>
      <summary class="flex min-h-13 cursor-pointer list-none items-center gap-3 rounded-xl px-4 py-3 font-medium text-stone-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700 [&::-webkit-details-marker]:hidden">
        <svg class="size-5 shrink-0 text-stone-500 group-open:text-emerald-700" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 7h11v9H3zM14 10h4l3 3v3h-7M7 19a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm10 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/></svg>
        <span class="flex-1">How long does delivery take?</span>
        <svg class="size-4 shrink-0 text-stone-500 group-open:rotate-180 group-open:text-emerald-700 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-4 pb-4 pl-12 text-sm leading-relaxed text-stone-700">Orders leave the studio in two working days. EU delivery takes 3 to 5 days, the UK and US 5 to 8.</p>
    </details>
    <details name="tac-ship" class="group rounded-xl border border-stone-200 bg-white open:border-emerald-600 open:bg-emerald-50/60 open:shadow-md">
      <summary class="flex min-h-13 cursor-pointer list-none items-center gap-3 rounded-xl px-4 py-3 font-medium text-stone-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700 [&::-webkit-details-marker]:hidden">
        <svg class="size-5 shrink-0 text-stone-500 group-open:text-emerald-700" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M4 8h16v12H4zM2 4h20v4H2zM10 12h4"/></svg>
        <span class="flex-1">How are the pieces packed?</span>
        <svg class="size-4 shrink-0 text-stone-500 group-open:rotate-180 group-open:text-emerald-700 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-4 pb-4 pl-12 text-sm leading-relaxed text-stone-700">Each piece is wrapped in recycled paper and set in a moulded pulp tray. No plastic, no foam peanuts.</p>
    </details>
    <details name="tac-ship" class="group rounded-xl border border-stone-200 bg-white open:border-emerald-600 open:bg-emerald-50/60 open:shadow-md">
      <summary class="flex min-h-13 cursor-pointer list-none items-center gap-3 rounded-xl px-4 py-3 font-medium text-stone-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700 [&::-webkit-details-marker]:hidden">
        <svg class="size-5 shrink-0 text-stone-500 group-open:text-emerald-700" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 14 4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3"/></svg>
        <span class="flex-1">Can I return an order?</span>
        <svg class="size-4 shrink-0 text-stone-500 group-open:rotate-180 group-open:text-emerald-700 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-4 pb-4 pl-12 text-sm leading-relaxed text-stone-700">Unused pieces can come back within 30 days. Print the label from your order page and we refund you when the parcel arrives.</p>
    </details>
    <details name="tac-ship" class="group rounded-xl border border-stone-200 bg-white open:border-emerald-600 open:bg-emerald-50/60 open:shadow-md">
      <summary class="flex min-h-13 cursor-pointer list-none items-center gap-3 rounded-xl px-4 py-3 font-medium text-stone-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700 [&::-webkit-details-marker]:hidden">
        <svg class="size-5 shrink-0 text-stone-500 group-open:text-emerald-700" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3 3 8l9 5 9-5zM3 8v8l9 5 9-5V8M12 13v8"/></svg>
        <span class="flex-1">What if something arrives broken?</span>
        <svg class="size-4 shrink-0 text-stone-500 group-open:rotate-180 group-open:text-emerald-700 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-4 pb-4 pl-12 text-sm leading-relaxed text-stone-700">Send a photo within 7 days and we ship a replacement from the next kiln firing, free of charge.</p>
    </details>
  </div>
</div>

Always open vs one at a time switch

  • has-checked:
  • has-focus-visible:
  • toggle event
  • name attribute

Click a question to open it.

The segmented control is two radio inputs hidden with sr-only inside labels, styled with has-checked: and has-focus-visible:. The script only adds or removes name="tac-mode" on the details elements (closing extra open items first) and counts open panels from the toggle event, so you can compare both behaviours on the same content.

View code
<div class="w-full max-w-lg rounded-2xl bg-white p-5 shadow-sm ring-1 ring-amber-900/10">
  <div class="flex flex-wrap items-center justify-between gap-3">
    <h2 class="text-base font-semibold text-amber-950">Workshop details</h2>
    <fieldset class="flex rounded-lg bg-amber-100 p-1 text-sm font-medium">
      <legend class="sr-only">Accordion behaviour</legend>
      <label class="cursor-pointer rounded-md px-3 py-2 text-amber-900 has-checked:bg-amber-950 has-checked:text-amber-50 has-focus-visible:outline-2 has-focus-visible:outline-offset-1 has-focus-visible:outline-amber-950">
        <input type="radio" name="tac-mode-pick" id="tac-mode-all" class="tac-mode-radio sr-only" checked>Always open
      </label>
      <label class="cursor-pointer rounded-md px-3 py-2 text-amber-900 has-checked:bg-amber-950 has-checked:text-amber-50 has-focus-visible:outline-2 has-focus-visible:outline-offset-1 has-focus-visible:outline-amber-950">
        <input type="radio" name="tac-mode-pick" id="tac-mode-one" class="tac-mode-radio sr-only">One at a time
      </label>
    </fieldset>
  </div>
  <p id="tac-mode-status" class="mt-3 text-xs font-medium text-amber-800" role="status">Always open. 1 of 3 panels open.</p>
  <div class="mt-3 divide-y divide-amber-900/10 border-y border-amber-900/10">
    <details class="tac-mode-item group" open>
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-amber-950 focus-visible:outline-2 focus-visible:outline-amber-950 [&::-webkit-details-marker]:hidden">
        <span>What do I need to bring?</span>
        <svg class="size-4 shrink-0 text-amber-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-stone-700">Only clothes that can get dusty. Aprons, tools and clay are on the bench when you arrive.</p>
    </details>
    <details class="tac-mode-item group">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-amber-950 focus-visible:outline-2 focus-visible:outline-amber-950 [&::-webkit-details-marker]:hidden">
        <span>When can I collect my pieces?</span>
        <svg class="size-4 shrink-0 text-amber-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-stone-700">About three weeks later, after the bisque and glaze firings. We send a text when they are ready.</p>
    </details>
    <details class="tac-mode-item group">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-amber-950 focus-visible:outline-2 focus-visible:outline-amber-950 [&::-webkit-details-marker]:hidden">
        <span>Can I move my booking?</span>
        <svg class="size-4 shrink-0 text-amber-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-stone-700">Yes, up to 48 hours before the session, from the link in your confirmation email.</p>
    </details>
  </div>
</div>

Smooth height with ::details-content

  • details-content:
  • [interpolate-size:allow-keywords]
  • transition-discrete
  • motion-safe:

Click a question to open it.

The details-content: variant targets the ::details-content pseudo-element: height 0 when closed, h-auto under open:. The arbitrary property [interpolate-size:allow-keywords] lets that height animate to auto, and transition-discrete lets content-visibility wait for the close animation. Everything that moves sits behind motion-safe:, and engines without the pseudo-element or interpolate-size just open instantly.

View code
<div class="w-full max-w-md rounded-2xl bg-white shadow-sm ring-1 ring-zinc-200">
  <div class="flex items-start justify-between gap-4 p-5">
    <div>
      <h2 class="text-lg font-semibold tracking-tight text-zinc-900">Ridgeline 3L shell</h2>
      <p class="mt-0.5 text-sm text-zinc-600">Waterproof jacket, 380 g</p>
    </div>
    <p class="text-lg font-semibold text-teal-800">$289</p>
  </div>
  <div class="divide-y divide-zinc-200 border-t border-zinc-200">
    <details class="group overflow-hidden details-content:h-0 details-content:overflow-clip open:details-content:h-auto motion-safe:[interpolate-size:allow-keywords] motion-safe:details-content:transition-[height,content-visibility] motion-safe:details-content:transition-discrete motion-safe:details-content:duration-300 motion-safe:details-content:ease-out">
      <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-4 px-5 py-3 text-sm font-semibold text-zinc-900 hover:text-teal-800 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
        <span>Materials</span>
        <svg class="size-4 shrink-0 text-zinc-500 group-open:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <ul class="space-y-1.5 px-5 pb-5 text-sm text-zinc-700">
        <li class="flex gap-2"><span class="mt-2 size-1.5 shrink-0 rounded-full bg-teal-600"></span>Three-layer recycled nylon face, 20,000 mm water column</li>
        <li class="flex gap-2"><span class="mt-2 size-1.5 shrink-0 rounded-full bg-teal-600"></span>Fluorocarbon-free water repellent finish</li>
        <li class="flex gap-2"><span class="mt-2 size-1.5 shrink-0 rounded-full bg-teal-600"></span>Taped seams and two-way front zip</li>
      </ul>
    </details>
    <details class="group overflow-hidden details-content:h-0 details-content:overflow-clip open:details-content:h-auto motion-safe:[interpolate-size:allow-keywords] motion-safe:details-content:transition-[height,content-visibility] motion-safe:details-content:transition-discrete motion-safe:details-content:duration-300 motion-safe:details-content:ease-out">
      <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-4 px-5 py-3 text-sm font-semibold text-zinc-900 hover:text-teal-800 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
        <span>Fit and sizing</span>
        <svg class="size-4 shrink-0 text-zinc-500 group-open:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <div class="px-5 pb-5 text-sm text-zinc-700">
        <p>Regular fit with room for a fleece underneath. The model is 183 cm and wears a medium.</p>
        <dl class="mt-3 grid grid-cols-3 gap-2 text-center">
          <div class="rounded-lg bg-zinc-100 px-2 py-2"><dt class="text-xs text-zinc-600">S chest</dt><dd class="font-semibold text-zinc-900">96 cm</dd></div>
          <div class="rounded-lg bg-zinc-100 px-2 py-2"><dt class="text-xs text-zinc-600">M chest</dt><dd class="font-semibold text-zinc-900">102 cm</dd></div>
          <div class="rounded-lg bg-zinc-100 px-2 py-2"><dt class="text-xs text-zinc-600">L chest</dt><dd class="font-semibold text-zinc-900">108 cm</dd></div>
        </dl>
      </div>
    </details>
    <details class="group overflow-hidden details-content:h-0 details-content:overflow-clip open:details-content:h-auto motion-safe:[interpolate-size:allow-keywords] motion-safe:details-content:transition-[height,content-visibility] motion-safe:details-content:transition-discrete motion-safe:details-content:duration-300 motion-safe:details-content:ease-out">
      <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-4 rounded-b-2xl px-5 py-3 text-sm font-semibold text-zinc-900 hover:text-teal-800 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
        <span>Care</span>
        <svg class="size-4 shrink-0 text-zinc-500 group-open:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="px-5 pb-5 text-sm text-zinc-700">Machine wash at 30 degrees with a technical wash, close all zips, then tumble dry low for 20 minutes to refresh the finish.</p>
    </details>
  </div>
</div>

Plus that turns into a minus

  • group-open:rotate-90
  • open:bg-*
  • ring-*
  • motion-safe:transition-transform

Click a question to open it.

The icon is two bars inside a circle. group-open:rotate-90 turns the vertical bar flat so it lies on the horizontal one, and the plus becomes a minus without swapping icons. open:bg-zinc-900 and open:ring-lime-300/40 lift the active item, and the rotation runs only under motion-safe:.

View code
<div class="w-full max-w-lg">
  <h2 class="text-xl font-semibold tracking-tight text-zinc-50">Working at Northpine</h2>
  <p class="mt-1 text-sm text-zinc-400">Answers for people applying to the studio.</p>
  <div class="mt-5 space-y-2">
    <details class="group rounded-2xl bg-zinc-900/60 ring-1 ring-zinc-800 open:bg-zinc-900 open:ring-lime-300/40" open>
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 rounded-2xl px-5 py-3 font-medium text-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-lime-300 [&::-webkit-details-marker]:hidden">
        <span>Is the role remote?</span>
        <span class="relative grid size-8 shrink-0 place-items-center rounded-full bg-zinc-800 text-zinc-200 group-open:bg-lime-300 group-open:text-zinc-950" aria-hidden="true">
          <span class="absolute h-0.5 w-3.5 rounded-full bg-current"></span>
          <span class="absolute h-3.5 w-0.5 rounded-full bg-current group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-300"></span>
        </span>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-zinc-400">Remote within European time zones. The team meets in Lisbon for one week every spring and autumn, travel paid.</p>
    </details>
    <details class="group rounded-2xl bg-zinc-900/60 ring-1 ring-zinc-800 open:bg-zinc-900 open:ring-lime-300/40">
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 rounded-2xl px-5 py-3 font-medium text-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-lime-300 [&::-webkit-details-marker]:hidden">
        <span>What does the interview look like?</span>
        <span class="relative grid size-8 shrink-0 place-items-center rounded-full bg-zinc-800 text-zinc-200 group-open:bg-lime-300 group-open:text-zinc-950" aria-hidden="true">
          <span class="absolute h-0.5 w-3.5 rounded-full bg-current"></span>
          <span class="absolute h-3.5 w-0.5 rounded-full bg-current group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-300"></span>
        </span>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-zinc-400">A 30-minute call, a portfolio walkthrough with two designers, and a paid half-day exercise. No whiteboard puzzles.</p>
    </details>
    <details class="group rounded-2xl bg-zinc-900/60 ring-1 ring-zinc-800 open:bg-zinc-900 open:ring-lime-300/40">
      <summary class="flex min-h-14 cursor-pointer list-none items-center justify-between gap-4 rounded-2xl px-5 py-3 font-medium text-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-lime-300 [&::-webkit-details-marker]:hidden">
        <span>Do you sponsor visas?</span>
        <span class="relative grid size-8 shrink-0 place-items-center rounded-full bg-zinc-800 text-zinc-200 group-open:bg-lime-300 group-open:text-zinc-950" aria-hidden="true">
          <span class="absolute h-0.5 w-3.5 rounded-full bg-current"></span>
          <span class="absolute h-3.5 w-0.5 rounded-full bg-current group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-300"></span>
        </span>
      </summary>
      <p class="px-5 pb-5 text-sm leading-relaxed text-zinc-400">For senior roles, yes. The job post says so when a role is open to sponsorship.</p>
    </details>
  </div>
</div>

Accordion with a dark mode toggle

  • dark:
  • @custom-variant dark
  • aria-pressed
  • dark:group-open:

Click a question to open it.

Every color has a dark: twin (bg-white dark:bg-slate-900, text-slate-600 dark:text-slate-300), and stacked variants such as dark:group-open:text-sky-300 style the open item in dark mode. The button toggles the dark class on the demo wrapper and its aria-pressed state, which works because the page uses the class-based @custom-variant dark line.

View code
<div id="tac-dm" class="w-full max-w-lg rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200 motion-safe:transition-colors dark:bg-slate-900 dark:ring-slate-700">
  <div class="flex items-center justify-between gap-3">
    <h2 class="text-base font-semibold text-slate-900 dark:text-white">Account and billing</h2>
    <button type="button" id="tac-dm-toggle" aria-pressed="false" class="group/btn inline-flex min-h-10 items-center gap-2 rounded-full border border-slate-300 px-3 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-600 dark:border-slate-600 dark:text-slate-200 dark:hover:bg-slate-800">
      <svg class="size-4 group-aria-pressed/btn:hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z"/></svg>
      <svg class="hidden size-4 group-aria-pressed/btn:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path stroke-linecap="round" d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
      Dark mode
    </button>
  </div>
  <div class="mt-4 divide-y divide-slate-200 dark:divide-slate-700">
    <details class="group" open>
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-slate-900 focus-visible:outline-2 focus-visible:outline-sky-600 group-open:text-sky-700 dark:text-slate-100 dark:group-open:text-sky-300 [&::-webkit-details-marker]:hidden">
        <span>When am I charged?</span>
        <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 dark:text-slate-400 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-slate-600 dark:text-slate-300">On the same day each month as your first payment. The receipt goes to the billing email in Settings.</p>
    </details>
    <details class="group">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-slate-900 focus-visible:outline-2 focus-visible:outline-sky-600 group-open:text-sky-700 dark:text-slate-100 dark:group-open:text-sky-300 [&::-webkit-details-marker]:hidden">
        <span>Can I get an invoice with a VAT number?</span>
        <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 dark:text-slate-400 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-slate-600 dark:text-slate-300">Add the number under Billing, Company details. Past invoices are reissued with it within a day.</p>
    </details>
    <details class="group">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 py-3 font-medium text-slate-900 focus-visible:outline-2 focus-visible:outline-sky-600 group-open:text-sky-700 dark:text-slate-100 dark:group-open:text-sky-300 [&::-webkit-details-marker]:hidden">
        <span>What happens to my data if I leave?</span>
        <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 dark:text-slate-400 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
      </summary>
      <p class="pb-4 text-sm leading-relaxed text-slate-600 dark:text-slate-300">You can export everything as CSV for 60 days. After that the workspace and its backups are deleted.</p>
    </details>
  </div>
</div>

Scripted accordions: ARIA buttons, search and steps

Patterns that need a few lines of JavaScript: the W3C APG button accordion with arrow keys, expand all, a searchable FAQ, a checkout that validates each step and panels that open from find-in-page.

ARIA button accordion (W3C APG pattern)

  • aria-expanded
  • aria-controls
  • role="region"
  • data-open:grid-rows-[1fr]

Tab to a header and press Enter or Space.

Each header is a button inside an h3, with aria-expanded and aria-controls, and each panel is a region labelled by its button, as in the W3C APG accordion pattern. The panel animates with grid-rows-[0fr] to data-open:grid-rows-[1fr] plus invisible and data-open:visible, so collapsed links leave the tab order. The script only flips aria-expanded and data-open: native buttons already handle Enter, Space and Tab, which is all the keyboard support the APG pattern asks for since April 2026.

View code
<div class="w-full max-w-lg rounded-2xl border border-violet-200 bg-white p-2 shadow-sm">
  <h3 class="m-0 font-sans text-base">
    <button type="button" id="tac-apg-b1" aria-expanded="true" aria-controls="tac-apg-p1" class="tac-apg-btn group flex min-h-12 w-full items-center justify-between gap-4 rounded-xl px-4 py-3 text-left font-semibold text-violet-950 hover:bg-violet-50 focus-visible:outline-2 focus-visible:outline-violet-600">
      <span>Signing webhook payloads</span>
      <svg class="size-4 shrink-0 text-violet-500 group-aria-expanded:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </button>
  </h3>
  <div id="tac-apg-p1" role="region" aria-labelledby="tac-apg-b1" data-open class="invisible grid grid-rows-[0fr] data-open:visible data-open:grid-rows-[1fr] motion-safe:transition-[grid-template-rows,visibility] motion-safe:duration-300 motion-safe:ease-out">
    <div class="overflow-hidden">
      <p class="px-4 pb-4 text-sm leading-relaxed text-slate-600">Every request carries a <code class="rounded bg-violet-50 px-1 font-mono text-xs text-violet-800">Relay-Signature</code> header. Hash the raw body with your signing secret and compare. <a href="#" class="font-medium text-violet-700 underline underline-offset-2 hover:text-violet-900 focus-visible:outline-2 focus-visible:outline-violet-600">See the sample code</a></p>
    </div>
  </div>
  <h3 class="m-0 font-sans text-base">
    <button type="button" id="tac-apg-b2" aria-expanded="false" aria-controls="tac-apg-p2" class="tac-apg-btn group flex min-h-12 w-full items-center justify-between gap-4 rounded-xl px-4 py-3 text-left font-semibold text-violet-950 hover:bg-violet-50 focus-visible:outline-2 focus-visible:outline-violet-600">
      <span>Retry schedule</span>
      <svg class="size-4 shrink-0 text-violet-500 group-aria-expanded:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </button>
  </h3>
  <div id="tac-apg-p2" role="region" aria-labelledby="tac-apg-b2" class="invisible grid grid-rows-[0fr] data-open:visible data-open:grid-rows-[1fr] motion-safe:transition-[grid-template-rows,visibility] motion-safe:duration-300 motion-safe:ease-out">
    <div class="overflow-hidden">
      <p class="px-4 pb-4 text-sm leading-relaxed text-slate-600">Failed deliveries are retried after 1, 5, 30 and 120 minutes. After the fifth failure the endpoint is paused and you get an email.</p>
    </div>
  </div>
  <h3 class="m-0 font-sans text-base">
    <button type="button" id="tac-apg-b3" aria-expanded="false" aria-controls="tac-apg-p3" class="tac-apg-btn group flex min-h-12 w-full items-center justify-between gap-4 rounded-xl px-4 py-3 text-left font-semibold text-violet-950 hover:bg-violet-50 focus-visible:outline-2 focus-visible:outline-violet-600">
      <span>Event types</span>
      <svg class="size-4 shrink-0 text-violet-500 group-aria-expanded:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </button>
  </h3>
  <div id="tac-apg-p3" role="region" aria-labelledby="tac-apg-b3" class="invisible grid grid-rows-[0fr] data-open:visible data-open:grid-rows-[1fr] motion-safe:transition-[grid-template-rows,visibility] motion-safe:duration-300 motion-safe:ease-out">
    <div class="overflow-hidden">
      <ul class="flex flex-wrap gap-2 px-4 pb-4 font-mono text-xs">
        <li class="rounded-md bg-violet-100 px-2 py-1 text-violet-900">order.created</li>
        <li class="rounded-md bg-violet-100 px-2 py-1 text-violet-900">order.paid</li>
        <li class="rounded-md bg-violet-100 px-2 py-1 text-violet-900">order.refunded</li>
        <li class="rounded-md bg-violet-100 px-2 py-1 text-violet-900">customer.deleted</li>
      </ul>
    </div>
  </div>
  <h3 class="m-0 font-sans text-base">
    <button type="button" id="tac-apg-b4" aria-expanded="false" aria-controls="tac-apg-p4" class="tac-apg-btn group flex min-h-12 w-full items-center justify-between gap-4 rounded-xl px-4 py-3 text-left font-semibold text-violet-950 hover:bg-violet-50 focus-visible:outline-2 focus-visible:outline-violet-600">
      <span>Testing locally</span>
      <svg class="size-4 shrink-0 text-violet-500 group-aria-expanded:rotate-180 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </button>
  </h3>
  <div id="tac-apg-p4" role="region" aria-labelledby="tac-apg-b4" class="invisible grid grid-rows-[0fr] data-open:visible data-open:grid-rows-[1fr] motion-safe:transition-[grid-template-rows,visibility] motion-safe:duration-300 motion-safe:ease-out">
    <div class="overflow-hidden">
      <p class="px-4 pb-4 text-sm leading-relaxed text-slate-600">Run <code class="rounded bg-violet-50 px-1 font-mono text-xs text-violet-800">relay listen --forward 3000</code> to tunnel test events to your machine.</p>
    </div>
  </div>
</div>

Release notes with expand all

  • details.open
  • toggle event
  • open:border-l-sky-600
  • tabular-nums

Use the controls, then try the keyboard.

The panels are native details, so each one still opens on its own. One button sets open on all of them or none, and its label flips between Expand all and Collapse all depending on the current state, which the script reads from the toggle event. open:border-l-sky-600 marks expanded releases with a colored edge.

View code
<div class="w-full max-w-lg rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
  <div class="flex flex-wrap items-center justify-between gap-3">
    <div>
      <h2 class="text-base font-semibold text-slate-900">Changelog</h2>
      <p id="tac-ex-status" class="text-xs text-slate-600" role="status">0 of 4 releases expanded</p>
    </div>
    <button type="button" id="tac-ex-btn" class="inline-flex min-h-10 items-center gap-2 rounded-lg bg-sky-700 px-3.5 text-sm font-semibold text-white hover:bg-sky-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700">
      <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m7 10 5-5 5 5M7 14l5 5 5-5"/></svg>
      <span id="tac-ex-label">Expand all</span>
    </button>
  </div>
  <div class="mt-4 space-y-2">
    <details class="tac-ex-item group rounded-lg border border-l-4 border-slate-200 border-l-slate-300 open:border-l-sky-600">
      <summary class="flex min-h-12 cursor-pointer list-none flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5 focus-visible:outline-2 focus-visible:outline-sky-700 [&::-webkit-details-marker]:hidden">
        <span class="font-mono text-sm font-semibold text-slate-900">v2.8.0</span>
        <span class="rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-800">Feature</span>
        <span class="ml-auto text-xs text-slate-600 tabular-nums">Oct 21, 2026</span>
      </summary>
      <ul class="list-disc space-y-1 pr-4 pb-4 pl-9 text-sm text-slate-700">
        <li>Shared views can now be filtered by assignee.</li>
        <li>CSV export keeps your column order.</li>
      </ul>
    </details>
    <details class="tac-ex-item group rounded-lg border border-l-4 border-slate-200 border-l-slate-300 open:border-l-sky-600">
      <summary class="flex min-h-12 cursor-pointer list-none flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5 focus-visible:outline-2 focus-visible:outline-sky-700 [&::-webkit-details-marker]:hidden">
        <span class="font-mono text-sm font-semibold text-slate-900">v2.7.3</span>
        <span class="rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-800">Fix</span>
        <span class="ml-auto text-xs text-slate-600 tabular-nums">Oct 9, 2026</span>
      </summary>
      <ul class="list-disc space-y-1 pr-4 pb-4 pl-9 text-sm text-slate-700">
        <li>Fixed due dates shifting by one day in UTC-10.</li>
        <li>The command menu no longer closes on paste.</li>
      </ul>
    </details>
    <details class="tac-ex-item group rounded-lg border border-l-4 border-slate-200 border-l-slate-300 open:border-l-sky-600">
      <summary class="flex min-h-12 cursor-pointer list-none flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5 focus-visible:outline-2 focus-visible:outline-sky-700 [&::-webkit-details-marker]:hidden">
        <span class="font-mono text-sm font-semibold text-slate-900">v2.7.0</span>
        <span class="rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-800">Feature</span>
        <span class="ml-auto text-xs text-slate-600 tabular-nums">Sep 24, 2026</span>
      </summary>
      <ul class="list-disc space-y-1 pr-4 pb-4 pl-9 text-sm text-slate-700">
        <li>Recurring tasks with custom intervals.</li>
        <li>Keyboard shortcut sheet on the question mark key.</li>
      </ul>
    </details>
    <details class="tac-ex-item group rounded-lg border border-l-4 border-slate-200 border-l-slate-300 open:border-l-sky-600">
      <summary class="flex min-h-12 cursor-pointer list-none flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5 focus-visible:outline-2 focus-visible:outline-sky-700 [&::-webkit-details-marker]:hidden">
        <span class="font-mono text-sm font-semibold text-slate-900">v2.6.1</span>
        <span class="rounded-full bg-rose-100 px-2 py-0.5 text-xs font-medium text-rose-800">Security</span>
        <span class="ml-auto text-xs text-slate-600 tabular-nums">Sep 2, 2026</span>
      </summary>
      <ul class="list-disc space-y-1 pr-4 pb-4 pl-9 text-sm text-slate-700">
        <li>Session tokens now expire after 14 days of inactivity.</li>
      </ul>
    </details>
  </div>
</div>

Searchable FAQ that opens matches

  • role="search"
  • hidden
  • focus-within:
  • role="status"

Type refund, pickup or gift into the search field.

Typing filters the questions: matching details elements open, the rest get the hidden attribute, and a status line announces the count. The field is a labelled search input with focus-within: styling on its wrapper, and an empty state appears when nothing matches. Clearing the field restores the closed list.

View code
<div class="w-full max-w-lg rounded-2xl bg-orange-50 p-5 ring-1 ring-orange-200">
  <h2 class="text-lg font-semibold tracking-tight text-stone-900">How can we help?</h2>
  <form role="search" id="tac-sf-form" class="mt-3">
    <label for="tac-sf-q" class="sr-only">Search the FAQ</label>
    <div class="flex min-h-12 items-center gap-2 rounded-xl border border-orange-300 bg-white px-3 focus-within:border-orange-600 focus-within:ring-3 focus-within:ring-orange-600/20">
      <svg class="size-5 shrink-0 text-stone-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path stroke-linecap="round" d="m20 20-3.5-3.5"/></svg>
      <input id="tac-sf-q" type="search" autocomplete="off" placeholder="Search questions" aria-describedby="tac-sf-status" class="min-w-0 flex-1 bg-transparent py-2 text-stone-900 placeholder:text-stone-500 focus:outline-none">
    </div>
  </form>
  <p id="tac-sf-status" class="mt-2 text-xs font-medium text-stone-600" role="status">6 questions</p>
  <div class="mt-3 space-y-2">
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">How fast do refunds arrive?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">Card refunds take 3 to 5 working days after we receive the return. Store credit is instant.</p>
    </details>
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">Can I collect my order in store?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">Choose pickup at checkout. Orders are ready in two hours at all twelve bakeries.</p>
    </details>
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">Do you sell gift cards?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">Digital gift cards from $10 to $200, sent by email on the date you pick. They never expire.</p>
    </details>
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">Are your loaves vegan?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">All sourdough loaves are. Brioche and the milk bun contain butter and egg.</p>
    </details>
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">What if my pickup is late?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">We hold orders until closing time. Unclaimed bread goes to the food bank and you get store credit.</p>
    </details>
    <details class="tac-sf-item group rounded-xl bg-white ring-1 ring-orange-200 open:ring-orange-400">
      <summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl px-4 py-3 text-sm font-semibold text-stone-900 focus-visible:outline-2 focus-visible:outline-orange-700 [&::-webkit-details-marker]:hidden">Do you cater events?<svg class="size-4 shrink-0 text-orange-700 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
      <p class="px-4 pb-4 text-sm text-stone-700">Yes, for 20 guests or more with a week of notice. Email events@example.com with the date.</p>
    </details>
  </div>
  <p id="tac-sf-empty" hidden class="mt-3 rounded-xl border border-dashed border-orange-300 px-4 py-6 text-center text-sm text-stone-600">No questions match. Try another word or call 555-0142.</p>
</div>

Checkout steps with validation

  • aria-disabled:
  • aria-invalid:
  • group-data-done:
  • novalidate

Press Continue with an empty field, then fill it in.

Each step is an APG-style header button and a region. Later steps carry aria-disabled="true" (styled with aria-disabled:) until the current form validates, and invalid fields get aria-invalid="true", which aria-invalid:border-red-600 picks up, plus an error message wired with aria-describedby. Finished steps get data-done, so group-data-done: swaps the empty ring for a check and shows a summary of the answer.

View code
<div class="w-full max-w-lg overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-sm">
  <div class="border-b border-neutral-200">
    <h3 class="m-0 font-sans text-base">
      <button type="button" id="tac-co-h1" aria-expanded="true" aria-controls="tac-co-p1" class="tac-co-head group flex min-h-14 w-full items-center gap-3 px-5 py-3 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-900 aria-disabled:cursor-not-allowed">
        <span class="grid size-6 shrink-0 place-items-center rounded-full border-2 border-neutral-300 group-aria-expanded:border-neutral-900 group-data-done:border-green-700 group-data-done:bg-green-700 group-data-done:text-white" aria-hidden="true"><svg class="hidden size-3.5 group-data-done:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="m5 12 5 5 9-10"/></svg></span>
        <span class="min-w-0 flex-1"><span class="block font-semibold text-neutral-900 group-aria-disabled:text-neutral-500">Contact</span><span class="tac-co-sum block truncate text-sm text-neutral-600"></span></span>
      </button>
    </h3>
    <div id="tac-co-p1" role="region" aria-labelledby="tac-co-h1">
      <form class="tac-co-form px-5 pb-5" novalidate>
        <label for="tac-co-email" class="block text-sm font-medium text-neutral-800">Email</label>
        <input id="tac-co-email" type="email" required autocomplete="email" placeholder="you@example.com" data-err="tac-co-e1" class="tac-co-field mt-1.5 block min-h-11 w-full rounded-lg border border-neutral-300 px-3 text-neutral-900 placeholder:text-neutral-500 focus:border-neutral-900 focus:outline-3 focus:outline-neutral-900/15 aria-invalid:border-red-600 aria-invalid:focus:outline-red-600/20">
        <p id="tac-co-e1" hidden class="mt-1.5 text-sm text-red-700">Enter an email address like name@example.com.</p>
        <button type="submit" class="mt-4 min-h-11 w-full rounded-lg bg-neutral-900 px-4 text-sm font-semibold text-white hover:bg-neutral-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900">Continue to delivery</button>
      </form>
    </div>
  </div>
  <div class="border-b border-neutral-200">
    <h3 class="m-0 font-sans text-base">
      <button type="button" id="tac-co-h2" aria-expanded="false" aria-controls="tac-co-p2" aria-disabled="true" class="tac-co-head group flex min-h-14 w-full items-center gap-3 px-5 py-3 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-900 aria-disabled:cursor-not-allowed">
        <span class="grid size-6 shrink-0 place-items-center rounded-full border-2 border-neutral-300 group-aria-expanded:border-neutral-900 group-data-done:border-green-700 group-data-done:bg-green-700 group-data-done:text-white" aria-hidden="true"><svg class="hidden size-3.5 group-data-done:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="m5 12 5 5 9-10"/></svg></span>
        <span class="min-w-0 flex-1"><span class="block font-semibold text-neutral-900 group-aria-disabled:text-neutral-500">Delivery</span><span class="tac-co-sum block truncate text-sm text-neutral-600"></span></span>
      </button>
    </h3>
    <div id="tac-co-p2" role="region" aria-labelledby="tac-co-h2" hidden>
      <form class="tac-co-form space-y-3 px-5 pb-5" novalidate>
        <div>
          <label for="tac-co-name" class="block text-sm font-medium text-neutral-800">Full name</label>
          <input id="tac-co-name" type="text" required autocomplete="name" data-err="tac-co-e2" class="tac-co-field mt-1.5 block min-h-11 w-full rounded-lg border border-neutral-300 px-3 text-neutral-900 focus:border-neutral-900 focus:outline-3 focus:outline-neutral-900/15 aria-invalid:border-red-600 aria-invalid:focus:outline-red-600/20">
          <p id="tac-co-e2" hidden class="mt-1.5 text-sm text-red-700">Enter the name for the parcel label.</p>
        </div>
        <div>
          <label for="tac-co-zip" class="block text-sm font-medium text-neutral-800">ZIP code</label>
          <input id="tac-co-zip" type="text" required inputmode="numeric" pattern="[0-9]{5}" autocomplete="postal-code" data-err="tac-co-e3" class="tac-co-field mt-1.5 block min-h-11 w-full max-w-40 rounded-lg border border-neutral-300 px-3 text-neutral-900 focus:border-neutral-900 focus:outline-3 focus:outline-neutral-900/15 aria-invalid:border-red-600 aria-invalid:focus:outline-red-600/20">
          <p id="tac-co-e3" hidden class="mt-1.5 text-sm text-red-700">Use five digits, for example 94107.</p>
        </div>
        <fieldset>
          <legend class="text-sm font-medium text-neutral-800">Shipping</legend>
          <div class="mt-1.5 grid gap-2 sm:grid-cols-2">
            <label class="flex min-h-11 cursor-pointer items-center gap-2 rounded-lg border border-neutral-300 px-3 text-sm text-neutral-800 has-checked:border-neutral-900 has-checked:bg-neutral-50"><input type="radio" name="tac-co-ship" value="Standard, free" class="accent-neutral-900" checked>Standard, free</label>
            <label class="flex min-h-11 cursor-pointer items-center gap-2 rounded-lg border border-neutral-300 px-3 text-sm text-neutral-800 has-checked:border-neutral-900 has-checked:bg-neutral-50"><input type="radio" name="tac-co-ship" value="Express, $12" class="accent-neutral-900">Express, $12</label>
          </div>
        </fieldset>
        <button type="submit" class="min-h-11 w-full rounded-lg bg-neutral-900 px-4 text-sm font-semibold text-white hover:bg-neutral-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900">Continue to payment</button>
      </form>
    </div>
  </div>
  <div>
    <h3 class="m-0 font-sans text-base">
      <button type="button" id="tac-co-h3" aria-expanded="false" aria-controls="tac-co-p3" aria-disabled="true" class="tac-co-head group flex min-h-14 w-full items-center gap-3 px-5 py-3 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-900 aria-disabled:cursor-not-allowed">
        <span class="grid size-6 shrink-0 place-items-center rounded-full border-2 border-neutral-300 group-aria-expanded:border-neutral-900 group-data-done:border-green-700 group-data-done:bg-green-700 group-data-done:text-white" aria-hidden="true"><svg class="hidden size-3.5 group-data-done:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="m5 12 5 5 9-10"/></svg></span>
        <span class="min-w-0 flex-1"><span class="block font-semibold text-neutral-900 group-aria-disabled:text-neutral-500">Review and pay</span><span class="tac-co-sum block truncate text-sm text-neutral-600"></span></span>
      </button>
    </h3>
    <div id="tac-co-p3" role="region" aria-labelledby="tac-co-h3" hidden>
      <form class="tac-co-form px-5 pb-5" novalidate>
        <dl class="divide-y divide-neutral-200 rounded-lg bg-neutral-50 px-4 text-sm">
          <div class="flex justify-between py-2"><dt class="text-neutral-600">Linen throw, oat</dt><dd class="font-medium text-neutral-900">$96.00</dd></div>
          <div class="flex justify-between py-2"><dt class="font-semibold text-neutral-900">Total</dt><dd class="font-semibold text-neutral-900">$96.00</dd></div>
        </dl>
        <label class="mt-3 flex cursor-pointer items-start gap-2 text-sm text-neutral-700"><input id="tac-co-terms" type="checkbox" required data-err="tac-co-e4" class="tac-co-field mt-0.5 size-4 accent-neutral-900">I agree to the terms of sale.</label>
        <p id="tac-co-e4" hidden class="mt-1.5 text-sm text-red-700">Tick the box to place the order.</p>
        <button type="submit" class="mt-4 min-h-11 w-full rounded-lg bg-green-700 px-4 text-sm font-semibold text-white hover:bg-green-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-700">Place order</button>
      </form>
    </div>
  </div>
  <p id="tac-co-done" hidden tabindex="-1" class="bg-green-50 px-5 py-4 text-sm font-medium text-green-800 focus:outline-none">Order placed. A confirmation is on its way to your inbox.</p>
</div>

Docs panels that open from find-in-page

  • hidden="until-found"
  • beforematch
  • aria-expanded
  • Preflight

Press Ctrl+F or Cmd+F and search for ferrum.toml or 78.

Collapsed panels use hidden="until-found" instead of display: none, so Chrome and Firefox can still find their text with Ctrl+F and fragment links. When that happens the browser fires beforematch and removes the attribute, and the script only syncs aria-expanded. Tailwind v4 Preflight leaves until-found alone, and browsers without it treat the panel as plain hidden, so the buttons keep working.

View code
<div class="w-full max-w-lg rounded-2xl bg-zinc-950 p-5 text-zinc-300 shadow-lg">
  <h2 class="font-mono text-base font-semibold text-emerald-300">ferrum deploy</h2>
  <p class="mt-1 text-sm text-zinc-400">Ships the current build to a target. Collapsed sections stay searchable: try finding <kbd class="rounded border border-zinc-700 bg-zinc-900 px-1 font-mono text-xs text-zinc-200">FERRUM_TOKEN</kbd> on this page.</p>
  <div class="mt-4 divide-y divide-zinc-800 rounded-xl ring-1 ring-zinc-800">
    <div>
      <h3 class="m-0 font-sans text-sm">
        <button type="button" aria-expanded="false" aria-controls="tac-uf-p1" class="tac-uf-btn group flex min-h-12 w-full items-center justify-between gap-4 px-4 py-3 text-left font-semibold text-zinc-100 hover:bg-zinc-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-emerald-300">Flags<svg class="size-4 shrink-0 text-zinc-500 group-aria-expanded:rotate-180 group-aria-expanded:text-emerald-300 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></button>
      </h3>
      <div id="tac-uf-p1" hidden="until-found">
        <dl class="space-y-2 px-4 pb-4 text-sm">
          <div><dt class="font-mono text-emerald-300">--target &lt;name&gt;</dt><dd class="text-zinc-400">Environment from ferrum.toml. Defaults to staging.</dd></div>
          <div><dt class="font-mono text-emerald-300">--dry-run</dt><dd class="text-zinc-400">Prints the plan and uploads nothing.</dd></div>
        </dl>
      </div>
    </div>
    <div>
      <h3 class="m-0 font-sans text-sm">
        <button type="button" aria-expanded="false" aria-controls="tac-uf-p2" class="tac-uf-btn group flex min-h-12 w-full items-center justify-between gap-4 px-4 py-3 text-left font-semibold text-zinc-100 hover:bg-zinc-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-emerald-300">Environment variables<svg class="size-4 shrink-0 text-zinc-500 group-aria-expanded:rotate-180 group-aria-expanded:text-emerald-300 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></button>
      </h3>
      <div id="tac-uf-p2" hidden="until-found">
        <p class="px-4 pb-4 text-sm text-zinc-400"><code class="font-mono text-emerald-300">FERRUM_TOKEN</code> overrides the stored login, which is handy in CI runners.</p>
      </div>
    </div>
    <div>
      <h3 class="m-0 font-sans text-sm">
        <button type="button" aria-expanded="false" aria-controls="tac-uf-p3" class="tac-uf-btn group flex min-h-12 w-full items-center justify-between gap-4 px-4 py-3 text-left font-semibold text-zinc-100 hover:bg-zinc-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-emerald-300">Exit codes<svg class="size-4 shrink-0 text-zinc-500 group-aria-expanded:rotate-180 group-aria-expanded:text-emerald-300 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></button>
      </h3>
      <div id="tac-uf-p3" hidden="until-found">
        <table class="mx-4 mb-4 w-[calc(100%-2rem)] text-left text-sm">
          <thead><tr class="text-zinc-500"><th class="py-1 pr-4 font-medium">Code</th><th class="py-1 font-medium">Meaning</th></tr></thead>
          <tbody class="text-zinc-300">
            <tr><td class="py-1 pr-4 font-mono text-emerald-300">0</td><td class="py-1">Deployed</td></tr>
            <tr><td class="py-1 pr-4 font-mono text-emerald-300">64</td><td class="py-1">Bad flag or missing target</td></tr>
            <tr><td class="py-1 pr-4 font-mono text-emerald-300">78</td><td class="py-1">Config error in ferrum.toml</td></tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

Accordion layouts for real pages

Full-width FAQ sections, a two-column pricing FAQ, help topics with icons, a nested course outline and a settings panel with switches inside. Still native details, arranged with grid and the md: breakpoint.

Full-width FAQ section

  • md:grid-cols-[2fr_3fr]
  • details name=""
  • border-b
  • group-open:rotate-45

Open a few panels at desktop and phone width.

A landing page section: the heading and contact link sit in the narrow column and the questions in the wide one from md: up, and they stack on phones. The items are an exclusive group with name="tac-loft", separated by plain border-b lines, and the plus rotates 45 degrees into a close mark with group-open:rotate-45.

View code
<div class="bg-[#f6f2eb] px-6 py-12 md:px-12 md:py-16">
  <div class="mx-auto grid max-w-5xl gap-8 md:grid-cols-[2fr_3fr] md:gap-12">
    <div>
      <h2 class="text-3xl font-semibold tracking-tight text-[#3b2a1e] text-balance">Questions before you book a desk</h2>
      <p class="mt-3 text-[#5c4a3d]">Loftway runs three coworking floors by the river. If your question is not here, the front desk answers within an hour.</p>
      <a href="#" class="mt-5 inline-flex min-h-11 items-center gap-2 rounded-full bg-[#9a3412] px-5 text-sm font-semibold text-white hover:bg-[#7c2d12] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9a3412]">Message the front desk</a>
    </div>
    <div class="border-t border-[#d8cbbb]">
      <details name="tac-loft" class="group border-b border-[#d8cbbb]" open>
        <summary class="flex min-h-16 cursor-pointer list-none items-center justify-between gap-6 py-4 text-lg font-medium text-[#3b2a1e] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9a3412] [&::-webkit-details-marker]:hidden">
          <span>Can I try a day before signing up?</span>
          <svg class="size-6 shrink-0 text-[#9a3412] group-open:rotate-45 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" d="M12 5v14M5 12h14"/></svg>
        </summary>
        <p class="pr-10 pb-5 leading-relaxed text-[#5c4a3d]">Yes. Your first day pass is free, coffee included. Book it online and bring a photo ID.</p>
      </details>
      <details name="tac-loft" class="group border-b border-[#d8cbbb]">
        <summary class="flex min-h-16 cursor-pointer list-none items-center justify-between gap-6 py-4 text-lg font-medium text-[#3b2a1e] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9a3412] [&::-webkit-details-marker]:hidden">
          <span>Are meeting rooms included?</span>
          <svg class="size-6 shrink-0 text-[#9a3412] group-open:rotate-45 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" d="M12 5v14M5 12h14"/></svg>
        </summary>
        <p class="pr-10 pb-5 leading-relaxed text-[#5c4a3d]">Every plan includes 4 room hours a month. Extra hours are $18 and can be booked from the app.</p>
      </details>
      <details name="tac-loft" class="group border-b border-[#d8cbbb]">
        <summary class="flex min-h-16 cursor-pointer list-none items-center justify-between gap-6 py-4 text-lg font-medium text-[#3b2a1e] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9a3412] [&::-webkit-details-marker]:hidden">
          <span>Can I bring my dog?</span>
          <svg class="size-6 shrink-0 text-[#9a3412] group-open:rotate-45 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" d="M12 5v14M5 12h14"/></svg>
        </summary>
        <p class="pr-10 pb-5 leading-relaxed text-[#5c4a3d]">On the second floor, yes. The ground and third floors stay pet-free for members with allergies.</p>
      </details>
      <details name="tac-loft" class="group border-b border-[#d8cbbb]">
        <summary class="flex min-h-16 cursor-pointer list-none items-center justify-between gap-6 py-4 text-lg font-medium text-[#3b2a1e] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9a3412] [&::-webkit-details-marker]:hidden">
          <span>Is there a minimum contract?</span>
          <svg class="size-6 shrink-0 text-[#9a3412] group-open:rotate-45 motion-safe:transition-transform motion-safe:duration-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" d="M12 5v14M5 12h14"/></svg>
        </summary>
        <p class="pr-10 pb-5 leading-relaxed text-[#5c4a3d]">No. Plans run month to month and you can cancel with 14 days of notice.</p>
      </details>
    </div>
  </div>
</div>

Pricing FAQ in two columns

  • @theme
  • md:grid-cols-2
  • items-start
  • open:bg-*

Open a few panels at desktop and phone width.

Two independent stacks of details sit in md:grid-cols-2 with items-start, so opening a question in one column does not stretch the other. The colors come from three prefixed @theme tokens (--color-tac-ink, --color-tac-cream, --color-tac-rust), which turns them into real utilities such as bg-tac-cream and text-tac-rust.

View code
<div class="w-full max-w-3xl rounded-3xl bg-tac-cream p-6 md:p-8">
  <h2 class="text-2xl font-semibold tracking-tight text-tac-ink">Pricing questions</h2>
  <p class="mt-1 text-sm text-tac-ink/80">Billing for Ledgerly, the bookkeeping app for small studios.</p>
  <div class="mt-6 grid items-start gap-3 md:grid-cols-2 md:gap-4">
    <div class="space-y-3">
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white">
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">Is there a free trial?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">30 days on the Studio plan, no card needed. You pick a plan when the trial ends.</p>
      </details>
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white">
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">How much is the yearly discount?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">Two months free. Studio is <span class="font-semibold text-tac-rust">$190 a year</span> instead of $228.</p>
      </details>
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white">
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">Do you charge per user?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">No. Plans include unlimited users, and your accountant gets a free seat.</p>
      </details>
    </div>
    <div class="space-y-3">
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white" open>
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">What happens if I switch plans?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">Upgrades apply at once and you pay the difference for the days left. Downgrades start with the next billing period.</p>
      </details>
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white">
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">Which payment methods work?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">Cards, SEPA direct debit and bank transfer on yearly plans.</p>
      </details>
      <details class="group rounded-xl border border-tac-ink/15 bg-white/60 open:bg-white">
        <summary class="flex min-h-13 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-4 py-3 text-sm font-semibold text-tac-ink focus-visible:outline-2 focus-visible:outline-tac-rust [&::-webkit-details-marker]:hidden">Do nonprofits get a discount?<svg class="size-4 shrink-0 text-tac-rust group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg></summary>
        <p class="px-4 pb-4 text-sm text-tac-ink/80">Registered charities get 40 percent off any plan. Send your registration number to billing@example.com.</p>
      </details>
    </div>
  </div>
</div>

Help topics with icons and descriptions

  • grid-cols-[auto_1fr_auto]
  • group-open:bg-*
  • group-hover:
  • truncate

Open a few panels at desktop and phone width.

The summary is a three-column grid, grid-cols-[auto_1fr_auto]: icon tile, title with a one-line description, chevron. Each tile has its own default palette pair, and group-open: deepens it to the solid color with white icon when the topic is open. The open panel lists the articles in that topic.

View code
<div class="w-full max-w-lg space-y-2">
  <details class="group rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 open:ring-sky-300">
    <summary class="grid min-h-16 cursor-pointer list-none grid-cols-[auto_1fr_auto] items-center gap-4 rounded-2xl p-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-600 [&::-webkit-details-marker]:hidden">
      <span class="grid size-11 place-items-center rounded-xl bg-sky-100 text-sky-700 group-open:bg-sky-600 group-open:text-white"><svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18M7 15h3"/></svg></span>
      <span class="min-w-0"><span class="block font-semibold text-slate-900">Billing and plans</span><span class="block truncate text-sm text-slate-600 group-hover:text-slate-700">Invoices, payment methods, refunds</span></span>
      <svg class="size-4 text-slate-400 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <ul class="space-y-1 px-4 pb-4 pl-[4.75rem] text-sm">
      <li><a href="#" class="block rounded py-1 text-sky-800 hover:underline focus-visible:outline-2 focus-visible:outline-sky-600">Download past invoices</a></li>
      <li><a href="#" class="block rounded py-1 text-sky-800 hover:underline focus-visible:outline-2 focus-visible:outline-sky-600">Change the card on file</a></li>
      <li><a href="#" class="block rounded py-1 text-sky-800 hover:underline focus-visible:outline-2 focus-visible:outline-sky-600">Request a refund</a></li>
    </ul>
  </details>
  <details class="group rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 open:ring-violet-300" open>
    <summary class="grid min-h-16 cursor-pointer list-none grid-cols-[auto_1fr_auto] items-center gap-4 rounded-2xl p-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-600 [&::-webkit-details-marker]:hidden">
      <span class="grid size-11 place-items-center rounded-xl bg-violet-100 text-violet-700 group-open:bg-violet-600 group-open:text-white"><svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><circle cx="9" cy="8" r="3.5"/><path stroke-linecap="round" d="M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M18 14.5a6.5 6.5 0 0 1 3.5 5.5"/></svg></span>
      <span class="min-w-0"><span class="block font-semibold text-slate-900">Team members</span><span class="block truncate text-sm text-slate-600 group-hover:text-slate-700">Invites, roles, removing access</span></span>
      <svg class="size-4 text-slate-400 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <ul class="space-y-1 px-4 pb-4 pl-[4.75rem] text-sm">
      <li><a href="#" class="block rounded py-1 text-violet-800 hover:underline focus-visible:outline-2 focus-visible:outline-violet-600">Invite people by email</a></li>
      <li><a href="#" class="block rounded py-1 text-violet-800 hover:underline focus-visible:outline-2 focus-visible:outline-violet-600">What each role can do</a></li>
      <li><a href="#" class="block rounded py-1 text-violet-800 hover:underline focus-visible:outline-2 focus-visible:outline-violet-600">Remove someone from the workspace</a></li>
    </ul>
  </details>
  <details class="group rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 open:ring-amber-300">
    <summary class="grid min-h-16 cursor-pointer list-none grid-cols-[auto_1fr_auto] items-center gap-4 rounded-2xl p-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600 [&::-webkit-details-marker]:hidden">
      <span class="grid size-11 place-items-center rounded-xl bg-amber-100 text-amber-800 group-open:bg-amber-600 group-open:text-white"><svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 3v4M15 3v4M6 7h12v4a6 6 0 0 1-12 0zM12 17v4"/></svg></span>
      <span class="min-w-0"><span class="block font-semibold text-slate-900">Integrations</span><span class="block truncate text-sm text-slate-600 group-hover:text-slate-700">Calendars, chat apps, webhooks</span></span>
      <svg class="size-4 text-slate-400 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <ul class="space-y-1 px-4 pb-4 pl-[4.75rem] text-sm">
      <li><a href="#" class="block rounded py-1 text-amber-900 hover:underline focus-visible:outline-2 focus-visible:outline-amber-600">Connect a calendar</a></li>
      <li><a href="#" class="block rounded py-1 text-amber-900 hover:underline focus-visible:outline-2 focus-visible:outline-amber-600">Send alerts to a chat channel</a></li>
    </ul>
  </details>
  <details class="group rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 open:ring-rose-300">
    <summary class="grid min-h-16 cursor-pointer list-none grid-cols-[auto_1fr_auto] items-center gap-4 rounded-2xl p-4 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-rose-600 [&::-webkit-details-marker]:hidden">
      <span class="grid size-11 place-items-center rounded-xl bg-rose-100 text-rose-700 group-open:bg-rose-600 group-open:text-white"><svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v12m0 0 4-4m-4 4-4-4M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/></svg></span>
      <span class="min-w-0"><span class="block font-semibold text-slate-900">Data export</span><span class="block truncate text-sm text-slate-600 group-hover:text-slate-700">CSV, JSON and full backups</span></span>
      <svg class="size-4 text-slate-400 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <ul class="space-y-1 px-4 pb-4 pl-[4.75rem] text-sm">
      <li><a href="#" class="block rounded py-1 text-rose-800 hover:underline focus-visible:outline-2 focus-visible:outline-rose-600">Export a project as CSV</a></li>
      <li><a href="#" class="block rounded py-1 text-rose-800 hover:underline focus-visible:outline-2 focus-visible:outline-rose-600">Schedule a weekly backup</a></li>
    </ul>
  </details>
</div>

Nested course outline

  • group/module
  • group-open/module:
  • group/lesson
  • group-open/lesson:

Open a few panels at desktop and phone width.

Modules and lessons are both details elements, so the groups are named: group/module on the outer level, group/lesson on the inner one. An unnamed group-open: would also match the open module, so every lesson chevron would rotate with it; group-open/lesson:rotate-180 reacts only to its own lesson.

View code
<div class="w-full max-w-lg rounded-2xl bg-white p-2 shadow-sm ring-1 ring-green-900/10">
  <details class="group/module rounded-xl open:bg-green-50" open>
    <summary class="flex min-h-14 cursor-pointer list-none items-center gap-3 rounded-xl px-3 py-3 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
      <svg class="size-5 shrink-0 text-green-700 group-open/module:rotate-90 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m9 6 6 6-6 6"/></svg>
      <span class="min-w-0 flex-1 font-semibold text-green-950">Getting started with layout</span>
      <span class="shrink-0 text-xs text-green-800 tabular-nums">3 lessons, 34 min</span>
    </summary>
    <div class="space-y-1 pr-2 pb-2 pl-10">
      <details class="group/lesson rounded-lg bg-white ring-1 ring-green-900/10" open>
        <summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm font-medium text-slate-800 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
          <span>Flexbox in ten minutes</span>
          <svg class="size-4 shrink-0 text-slate-500 group-open/lesson:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
        </summary>
        <p class="px-3 pb-3 text-sm text-slate-600">Main axis, cross axis and the three properties you will use every day. Video, 10 min.</p>
      </details>
      <details class="group/lesson rounded-lg bg-white ring-1 ring-green-900/10">
        <summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm font-medium text-slate-800 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
          <span>Grid for page layouts</span>
          <svg class="size-4 shrink-0 text-slate-500 group-open/lesson:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
        </summary>
        <p class="px-3 pb-3 text-sm text-slate-600">Named areas, fr units and when to pick grid over flex. Video, 14 min.</p>
      </details>
      <details class="group/lesson rounded-lg bg-white ring-1 ring-green-900/10">
        <summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm font-medium text-slate-800 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
          <span>Exercise: a pricing page</span>
          <svg class="size-4 shrink-0 text-slate-500 group-open/lesson:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
        </summary>
        <p class="px-3 pb-3 text-sm text-slate-600">Rebuild a three-tier pricing table from a screenshot. Starter files included, 10 min.</p>
      </details>
    </div>
  </details>
  <details class="group/module rounded-xl open:bg-green-50">
    <summary class="flex min-h-14 cursor-pointer list-none items-center gap-3 rounded-xl px-3 py-3 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
      <svg class="size-5 shrink-0 text-green-700 group-open/module:rotate-90 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m9 6 6 6-6 6"/></svg>
      <span class="min-w-0 flex-1 font-semibold text-green-950">Responsive design</span>
      <span class="shrink-0 text-xs text-green-800 tabular-nums">2 lessons, 25 min</span>
    </summary>
    <div class="space-y-1 pr-2 pb-2 pl-10">
      <details class="group/lesson rounded-lg bg-white ring-1 ring-green-900/10">
        <summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm font-medium text-slate-800 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
          <span>Breakpoints that follow content</span>
          <svg class="size-4 shrink-0 text-slate-500 group-open/lesson:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
        </summary>
        <p class="px-3 pb-3 text-sm text-slate-600">Pick breakpoints where the layout breaks, not where devices are. Video, 12 min.</p>
      </details>
      <details class="group/lesson rounded-lg bg-white ring-1 ring-green-900/10">
        <summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm font-medium text-slate-800 focus-visible:outline-2 focus-visible:outline-green-700 [&::-webkit-details-marker]:hidden">
          <span>Container queries</span>
          <svg class="size-4 shrink-0 text-slate-500 group-open/lesson:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
        </summary>
        <p class="px-3 pb-3 text-sm text-slate-600">Cards that adapt to their column instead of the viewport. Video, 13 min.</p>
      </details>
    </div>
  </details>
</div>

Settings accordion with switches inside

  • peer-checked:
  • role="switch"
  • after:
  • peer-focus-visible:

Open a section and flip a switch.

Each switch is a real checkbox with role="switch", hidden with sr-only and followed by a peer track: peer-checked:bg-teal-600 colors it and peer-checked:after:translate-x-5 slides the knob drawn with after:. The script only counts checked switches per section and writes the summary badge, so the closed panel still tells you what is on.

View code
<div class="w-full max-w-lg divide-y divide-slate-200 rounded-2xl bg-white shadow-sm ring-1 ring-slate-200">
  <details class="tac-st-item group" open>
    <summary class="flex min-h-14 cursor-pointer list-none items-center gap-3 px-5 py-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
      <span class="min-w-0 flex-1 font-semibold text-slate-900">Notifications</span>
      <span class="tac-st-count rounded-full bg-teal-50 px-2 py-0.5 text-xs font-medium text-teal-800 ring-1 ring-teal-200">2 of 3 on</span>
      <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <div class="space-y-1 px-5 pb-4">
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Mentions</span><span class="block text-xs text-slate-600">When someone tags you in a comment</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only" checked>
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Weekly digest</span><span class="block text-xs text-slate-600">A Monday summary of open tasks</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only" checked>
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Product news</span><span class="block text-xs text-slate-600">New features, at most once a month</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only">
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
    </div>
  </details>
  <details class="tac-st-item group">
    <summary class="flex min-h-14 cursor-pointer list-none items-center gap-3 px-5 py-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
      <span class="min-w-0 flex-1 font-semibold text-slate-900">Privacy</span>
      <span class="tac-st-count rounded-full bg-teal-50 px-2 py-0.5 text-xs font-medium text-teal-800 ring-1 ring-teal-200">1 of 2 on</span>
      <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <div class="space-y-1 px-5 pb-4">
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Show my status</span><span class="block text-xs text-slate-600">Teammates see when you are online</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only" checked>
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Read receipts</span><span class="block text-xs text-slate-600">Let senders know you opened a message</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only">
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
    </div>
  </details>
  <details class="tac-st-item group">
    <summary class="flex min-h-14 cursor-pointer list-none items-center gap-3 px-5 py-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-teal-700 [&::-webkit-details-marker]:hidden">
      <span class="min-w-0 flex-1 font-semibold text-slate-900">Security</span>
      <span class="tac-st-count rounded-full bg-teal-50 px-2 py-0.5 text-xs font-medium text-teal-800 ring-1 ring-teal-200">0 of 2 on</span>
      <svg class="size-4 shrink-0 text-slate-500 group-open:rotate-180 motion-safe:transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="m6 9 6 6 6-6"/></svg>
    </summary>
    <div class="space-y-1 px-5 pb-4">
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">Two-step sign-in</span><span class="block text-xs text-slate-600">Ask for a code from an authenticator app</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only">
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
      <label class="flex min-h-12 cursor-pointer items-center justify-between gap-4">
        <span class="min-w-0"><span class="block text-sm font-medium text-slate-900">New device alerts</span><span class="block text-xs text-slate-600">Email me when a new device signs in</span></span>
        <input type="checkbox" role="switch" class="tac-st-sw peer sr-only">
        <span class="relative h-6 w-11 shrink-0 rounded-full bg-slate-300 peer-checked:bg-teal-600 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-teal-700 after:absolute after:top-0.5 after:left-0.5 after:size-5 after:rounded-full after:bg-white after:shadow-sm peer-checked:after:translate-x-5 motion-safe:transition-colors motion-safe:after:transition-transform" aria-hidden="true"></span>
      </label>
    </div>
  </details>
</div>

How to build a Tailwind accordion with details and summary

Tailwind doesn’t ship an accordion component. What you get is native details and summary elements with utility classes on top.

The browser handles the toggle and the keyboard activation, and it adds the open attribute for you. Tailwind just does spacing, borders and state styling.

Because the structure is plain HTML, the panels still open and close when a script fails to load.

A hand-written CSS accordion needs a stylesheet entry for every state. Here the same job lives in class names on the elements.

  1. Wrap each item in a details element and put the question inside a summary.
  2. Add group to the details so its children can react to the open state.
  3. Hide the default marker with list-none on the summary, plus [&::-webkit-details-marker]:hidden for WebKit builds that still draw it.
  4. Lay out the summary with flex items-center justify-between gap-4 cursor-pointer so the icon sits at the far edge.
  5. Add the chevron SVG after the label with transition-transform group-open:rotate-180.
  6. Pad the panel text, and add the open attribute to any item that should start expanded.
  7. Put divide-y on the wrapper to separate the items.
<div class="divide-y divide-slate-200">
  <details class="group py-3" open>
    <summary class="flex cursor-pointer list-none items-center justify-between gap-4 [&::-webkit-details-marker]:hidden">
      <span class="font-medium">What does the plan include?</span>
      <svg class="size-4 transition-transform duration-200 group-open:rotate-180" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
    </summary>
    <p class="pt-2 text-sm text-slate-600">Three projects and email support.</p>
  </details>
</div>

Style the open state

The only real difference between the variants is which element carries the state. The open: variant styles the details element itself, for example open:bg-slate-50. group-open: reaches any descendant of a group parent, like the icon or the panel text. And peer-open: styles a sibling that follows an element marked peer, which lets a panel outside the details react to it.

In Tailwind v4 the open variant matches both the open attribute and the :open pseudo-class, a change listed under the 4.0.1 release of January 29, 2025 in the Tailwind CSS changelog.

Nested accordions need named groups. An unnamed group-open: matches any open ancestor, so an inner icon would rotate when only the outer item is open.

Name the outer group with group/outer and target it with group-open/outer:. Rails Designer’s no-JavaScript tutorial uses the same group/details pattern.

Rotate the icon or swap plus for minus

I’d take an inline SVG chevron over an icon font every time. It inherits currentColor and rotates with one class, so nothing extra loads.

For a plus-minus swap, stack two icons. Put group-open:hidden on the plus and hidden group-open:block on the minus.

How to animate the accordion panel height

Transition grid-template-rows from 0fr to 1fr on a wrapper around the panel content.

A height swap from 0 to auto cannot interpolate, so the panel snaps open (Cruip). The grid method needs no fixed heights and no script to measure the content.

Grid track animation is supported from Chrome 107, Edge 107, Firefox 66 and Safari 16 (web.dev).

Grid-template-rows method

The wrapper is a grid with grid-rows-[0fr] when closed and grid-rows-[1fr] when open. Its single child needs overflow-hidden, or the content shows through the collapsed row.

With native details, mark the details as peer and place the wrapper right after it.

<details class="peer group">
  <summary class="flex cursor-pointer list-none items-center justify-between py-3 [&::-webkit-details-marker]:hidden">
    <span class="font-medium">Do you ship abroad?</span>
    <svg class="size-4 transition-transform duration-200 group-open:rotate-180" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
  </summary>
</details>
<div class="invisible grid grid-rows-[0fr] transition-[grid-template-rows,visibility] duration-300 ease-in-out peer-open:visible peer-open:grid-rows-[1fr]">
  <div class="overflow-hidden">
    <p class="pb-4 text-sm text-slate-600">Yes, we ship worldwide.</p>
  </div>
</div>

The invisible class matters. A collapsed row still holds its links, and without it they stay in the tab order.

The catch is that a sibling panel gives up the find-in-page auto-expand that native details provides (Chrome for Developers, 2024). Content with visibility: hidden is skipped by the search.

Easing is the part worth previewing before you commit to a duration, so try a few curves in the browser before you settle on one.

max-height method

Set max-h-0 when closed and a cap such as max-h-96 when open. The cap must be larger than the tallest panel, or the content gets clipped.

Closing also feels delayed when the cap is far taller than the content, because the timer runs against the cap and not the real height.

Native animation with ::details-content

Native details can now animate without a sibling wrapper. Tailwind v4.1 added a details-content variant for the pseudo-element, and the transition-discrete utility sets transition-behavior: allow-discrete (Tailwind CSS documentation).

The ::details-content pseudo-element works in Chrome 131, Edge 131, Firefox 143 and Safari 18.4 (MDN browser compatibility data).

Then there’s interpolate-size: allow-keywords, which lets height animate to auto. It ships in Chrome 129 and Edge 129, and Firefox and Safari still do not support it as of October 2026 (MDN browser compatibility data), so wrap it in @supports.

Where support is missing, the accordion still works. Visitors only lose the animation.

Why a group-open fade does nothing

A group-open:opacity-100 transition on a panel inside details shows no animation. Closed content is not rendered, so the transition has nothing to start from.

On engines with ::details-content, the content-visibility flip is a discrete property. The transition needs transition-discrete as well, per the same Chrome for Developers article.

How to let only one panel stay open at a time

Give every details element in the group the same name attribute, and the browser closes the open one whenever another opens.

Tailwind has no utility for this. It is plain HTML, so the open: and group-open: styling keeps working unchanged.

<details name="shipping" class="group">
  <summary>Delivery times</summary>
  <p>Orders leave the warehouse in two working days.</p>
</details>
<details name="shipping" class="group">
  <summary>Returns</summary>
  <p>Unused items can be sent back within 30 days.</p>
</details>

Chrome and Edge support the name attribute from version 120 (Chrome for Developers, 2023). Safari picked it up in 17.2 and Firefox in 130. Baseline status has been newly available since September 3, 2024, with widely available status expected on March 3, 2027 (Web Platform DX feature explorer).

Multi-open is the default

Without a name, each details element toggles on its own, so several panels can stay open together.

Exclusive grouping is not always the better choice. The HTML Living Standard asks authors to weigh whether it helps or harms users, and Chrome’s team notes that visitors may have to open many items to read everything.

Grouping rules

  • Members do not need to be siblings, because the name groups them and DOM order does not (Chrome for Developers)
  • A new name value starts a separate group, so one page can hold several exclusive accordions
  • Only one member of a group may carry the open attribute in the markup (HTML Living Standard)
  • A details element cannot sit inside another member of its own group

Fallback for older browsers

The polyfill listens for the toggle event, finds the other open items with the same name and removes their open attribute (Chrome for Developers). It takes a few lines of JavaScript.

Basecoat UI ships its own script for the job instead. Its accordion keeps native details for the disclosure semantics, and the JavaScript enforces single-item behavior unless the root carries data-multiple (Basecoat UI documentation).

Check the support floors against your own cross-browser compatibility targets before dropping the script.

Browsers that do not fire the toggle event simply stay multi-open, which Chrome’s documentation calls acceptable progressive enhancement.

How to build a JavaScript-driven accordion with Alpine.js or React

Use a button and panel pair when the animation has to be exact, or when your framework needs to read the open state.

The markup contract is the same in every variant. The button carries aria-expanded and aria-controls, and the panel gets a matching id and role="region".

Cruip’s published Alpine.js version flips between grid-rows-[1fr] opacity-100 and grid-rows-[0fr] opacity-0 from a single expanded flag. The panel carries transition-all duration-300 ease-in-out.

Alpine.js

<div x-data="{ expanded: false }" class="border-b border-slate-200 py-2">
<button type="button" class="flex w-full items-center justify-between py-2 text-left font-medium" @click="expanded = !expanded" :aria-expanded="expanded" aria-controls="faq-1">
<span>Is there a free plan?</span>
<svg class="size-4 transition-transform duration-200" :class="expanded && 'rotate-180'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
</button>
<div id="faq-1" role="region" class="grid text-sm text-slate-600 transition-all duration-300 ease-in-out" :class="expanded ? 'visible grid-rows-[1fr] opacity-100' : 'invisible grid-rows-[0fr] opacity-0'">
<div class="overflow-hidden">
<p class="pb-3">Yes. The free plan covers three projects.</p>
</div>
</div>
</div>

The visible and invisible classes are an addition to Cruip’s pattern. They keep collapsed links out of the tab order.

Alpine’s Collapse plugin is another route, and it animates height for you. It only works on an element that already has x-show, and the collapsed state sets height to 0px plus display: none by default (Alpine documentation).

The plugin script must load before Alpine’s core file.

React

Store the open item in one piece of state, such as const [openId, setOpenId] = useState(null). Comparing each item’s id to that value gives single-open behavior, and an array of ids gives multi-open.

The panel classes are the same grid classes, picked by a conditional string. If Tailwind is not wired into your build yet, start with the setup for Tailwind CSS in React.

Headless UI Disclosure

Disclosure and its button and panel parts manage the open state, and Enter or Space toggles the panel (Headless UI documentation). Styling is left entirely to you.

The open state reaches your classes through a render prop or data attributes. v2.1 reworked the transition API, so check your installed version before copying a snippet.

For a static FAQ, native details wins on weight. Headless UI earns its place when the accordion sits next to other Headless UI components.

Every build in this section depends on the script. Native details does not.

Which prebuilt library gives you a Tailwind accordion?

It comes down to how much JavaScript you accept. daisyUI needs none, Flowbite and Preline UI need their scripts, and shadcn/ui needs React.

All of them give you open-and-close behavior with Tailwind classes, and each charges a different price for it (as of October 2026).

Flowbite

Flowbite drives the accordion from data attributes.

  • data-accordion="collapse" keeps one child open at a time
  • data-accordion="open" keeps several children open
  • Each header button carries data-accordion-target, aria-expanded and aria-controls

One attribute switches the mode, the ARIA attributes are already in the markup, and the core components are MIT-licensed (Flowbite documentation). The downside is that it needs Flowbite’s JavaScript, and it adds a data-attribute convention on top of your own classes.

daisyUI

daisyUI adds accordion styling as component classes, with no script involved. You write collapse, collapse-title and collapse-content, plus collapse-arrow or collapse-plus for the icon.

Exclusive behavior comes from radio inputs or details elements that share a name, and a second accordion on the page needs a different name (daisyUI documentation).

The details variant keeps collapsed text searchable in the browser, and the icon modifiers replace hand-built SVG rotation. That’s most of the appeal, since there’s no JavaScript at all.

Some rough edges exist. The collapse-open and collapse-close modifiers do not work with the details variant, so the open attribute does that job. The checkbox and radio variants hide collapsed text from in-browser search, which is why the docs point to the details variant.

Preline UI

Preline’s accordion page carries a “Requires JS” label.

Setup starts with npm i @preline/accordion. After that comes an @source line plus the plugin’s variants.css and theme.css imports in your Tailwind CSS file, and last the plugin script.

Markup uses hs-accordion, hs-accordion-toggle and hs-accordion-content. A global HSAccordion object exposes methods such as show() for programmatic control.

In return you get a JavaScript API, lifecycle events, ARIA attributes built in and a height transition on the panel. What it costs is a plugin script and an extra import step in your Tailwind CSS file.

shadcn/ui and Radix UI

The shadcn/ui accordion is copied into your project with pnpm dlx shadcn@latest add accordion. Its docs now default to a Base UI version and also offer React Aria and Radix UI versions. Supabase’s design system documents its accordion as a Radix UI component built with shadcn/ui.

In the Radix UI version, with type="single" and collapsible, the open item can close again. type="multiple" allows several open at once. For styling, data-state reads open or closed on the trigger and content, so data-[state=open]: variants work.

Animation takes a bit more setup. Radix exposes --radix-accordion-content-height, and its docs animate height from 0 to that variable with keyframes.

The upside is accessibility handled for you, since the component follows the WAI-ARIA accordion pattern (Radix UI documentation).

The downside is React-only code, Radix as a dependency, and keyframes you register yourself.

How to make a Tailwind accordion accessible

The WAI-ARIA Authoring Practices accordion pattern sets the keyboard rules.

  • Enter or Space toggles the panel of the focused header
  • Tab and Shift+Tab move through all focusable elements in the accordion, panel links included

Native details covers both. The pattern used to list Down Arrow, Up Arrow, Home and End as optional extras, but the APG editors removed them in April 2026. Radix UI still ships those keys, which does no harm.

Red Hat’s design system describes the same model, with each panel header as a focus stop where Enter or Space expands or collapses it.

Native elements already carry their own semantics, so extra ARIA roles on a summary cause trouble.

Native summary support is uneven

On paper it looks fine. Most browsers expose the summary element as a button, so screen readers announce it as one, and W3C’s ARIA in HTML allows no role attribute on a summary that labels its details.

Real-world results look worse. a11ysupport.io lists the summary element at partial support, 38/44 for screen readers and 5/13 for voice control, and warns that its oldest results are five years old.

The two disagree because one describes the specified mapping and the other records what real browser and screen reader pairs do.

Scott O’Hara’s 2018 write-up found the same gap. With role="button" added to a summary, NVDA with Chrome stopped announcing the state change, and VoiceOver could no longer reach a heading nested inside.

Use the bare summary. The override removes the state announcement instead of fixing the gap.

Headings, focus and motion

Header buttons in custom builds belong inside a heading element.

Flowbite wraps its button in an h2, and Radix UI’s Accordion.Header wraps the trigger, with asChild to set the level for your page.

  • In native details, keep headings out of the summary because screen readers handle them unevenly. JAWS does not announce a heading inside a summary, TalkBack ignores it, and NVDA with Chrome stopped announcing the state change when one sat inside (Scott O’Hara, 2018 tests)
  • Match the heading level to the page outline, not to the accordion’s visual size
  • Add focus-visible:ring-2 to every summary or button, since outline-none removes the default focus indicator
  • Put motion-reduce:transition-none on animated panels and icons, a variant Tailwind has shipped since v1.6.0 (Tailwind CSS blog)

Where Tailwind accordions break

Most failures come from a script that never loads or a layout assumption that clashes with ::details-content. The other kind comes from content that never belonged in an accordion.

When the script does not load

Flowbite and Preline UI both need their JavaScript before anything opens.

Flowbite’s collapsed panels carry the hidden class in the published markup, so the text stays hidden if the script never runs. Preline’s published markup does the same, with hidden on every collapsed hs-accordion-content panel.

Native details and daisyUI’s details variant degrade differently. The text stays reachable, and the toggle belongs to the browser.

When ::details-content changes your layout

Chrome 131 (November 2024) set the display of ::details-content to block in the user-agent stylesheet, where it used to behave as display: contents.

Panel content that relies on height: 100% can break as a result.

Chrome’s documentation gives the workaround, details[open]::details-content { display: contents; }, which restores the old behavior.

When the content should not be hidden at all

An accordion hides text by default. It suits secondary answers, not anything a visitor must read to decide.

Pricing terms and legal limits should stay in plain view. So should steps the reader has to follow in order. Sections that visitors compare side by side are a poor fit too.

For parallel views of equal weight, a Tailwind tabs layout shows every label at once. Plain headings with open text handle the rest.

How to choose between native, JavaScript and library accordions

Use native details unless you need behavior it cannot give you, and reach for a library only when the rest of your interface already runs on one.

ApproachJavaScriptAnimationSingle-open
Native detailsNoneGrid sibling or ::details-contentname attribute
JavaScript-driven buildRequiredGrid classes or Alpine’s Collapse pluginShared state
Prebuilt libraryDepends on the libraryBuilt in, or keyframes you addProp, attribute or shared name

A static FAQ or docs page is well served by native details with group-open: styling. If the open state feeds other UI, go with a JavaScript-driven build, because the state has to live in a variable something else can read. And when the project already sits on a component system, use that system’s accordion so buttons, modals and accordions share one set of tokens.

Each step up adds weight. A JavaScript build adds the script and the ARIA wiring, and a library adds a dependency plus a convention to learn.

Out of the box, native details brings disclosure semantics (with the uneven screen reader support described above), and daisyUI’s details variant inherits them. Flowbite’s markup includes ARIA attributes, Radix UI follows the WAI-ARIA accordion pattern, and in a hand-built build the wiring is yours.

Installing a library for a single FAQ is overbuilt. If one is justified, daisyUI’s details variant costs the least, since it needs no script.

Tailwind accordion FAQ

How do you style a Tailwind accordion for dark mode?

Add dark: variants to the summary, panel and border classes, such as bg-white dark:bg-slate-900.

In Tailwind v4 the variant follows prefers-color-scheme with no setup. A manual toggle needs @custom-variant dark (&:where(.dark, .dark *)); in your CSS.

Does the accordion code change in Tailwind v4?

Not much. The group-open:, open: and peer-open: classes work the same way.

The difference is how variants combine. Stacked variants apply left to right in v4, not right to left, so reorder any stack carried over from v3.

Can you nest accordions inside each other?

Yes. Name the groups group/outer and group/inner, and style each level with group-open/outer: or group-open/inner:.

With the grid height method, the outer row grows as the inner panel opens. In single-open mode, give the inner details a different name value than the outer ones.

How do you change the animation speed?

Set a duration utility on the element that carries the transition, such as duration-500 for 500ms, or duration-[400ms] for a one-off value.

The panel and the chevron transition separately, so give both the same duration or the icon finishes before the panel does.

How to check a Tailwind accordion before launch

Test keyboard operation first, then screen reader announcements, and last the oldest browser on your support list.

Keyboard checks need no extra software. Screen reader results decide whether native summary markup stays, and a missing browser feature costs only the animation or the single-open behavior, never the toggle.

In every engine, the ::details-content release comes later than the name attribute release, so the animation feature sets the floor for a fully native build.

Reassess the sibling panel once the oldest supported browser clears that floor (position verified October 2026).

A full web accessibility checklist extends the same checks to the rest of the page.