SolutionsCase StudiesAI ToolsResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/tailwind-faq-accordions

6 Tailwind FAQ Accordions

4 Tailwind2 with JSPublished 2026-10-05Free · no sign-up

Six FAQ sections in Tailwind: a native details list, an exclusive accordion that keeps one answer open, plus icons that turn into minus signs, an accordion with animated height, a FAQ with a search box and a numbered dark version.

01. Tailwind FAQ with details and summary

TailwindFAQDetails

The simplest accessible FAQ: native details and summary elements, which open and close with no script and work with keyboard and screen readers out of the box. group-open:rotate-180 turns the chevron.

View code
<div class="w-full max-w-sm divide-y divide-slate-200 rounded-2xl bg-white shadow-sm ring-1 ring-slate-200">
  <details class="group p-4" open><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-slate-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-indigo-600 [&::-webkit-details-marker]:hidden">How long does shipping take?<svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-5 shrink-0 text-slate-500 transition-transform group-open:rotate-180"><path d="M5.2 7.5a.75.75 0 0 1 1.06 0L10 11.2l3.7-3.7a.75.75 0 1 1 1.06 1.06l-4.23 4.24a.75.75 0 0 1-1.06 0L5.2 8.56a.75.75 0 0 1 0-1.06z"/></svg></summary><p class="mt-2 text-sm text-slate-600">Most orders arrive in 2 to 4 working days.</p></details>
  <details class="group p-4"><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-slate-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-indigo-600 [&::-webkit-details-marker]:hidden">Can I return an item?<svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-5 shrink-0 text-slate-500 transition-transform group-open:rotate-180"><path d="M5.2 7.5a.75.75 0 0 1 1.06 0L10 11.2l3.7-3.7a.75.75 0 1 1 1.06 1.06l-4.23 4.24a.75.75 0 0 1-1.06 0L5.2 8.56a.75.75 0 0 1 0-1.06z"/></svg></summary><p class="mt-2 text-sm text-slate-600">Yes, within 30 days, as long as it is unworn.</p></details>
  <details class="group p-4"><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-slate-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-indigo-600 [&::-webkit-details-marker]:hidden">Do you ship abroad?<svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" class="size-5 shrink-0 text-slate-500 transition-transform group-open:rotate-180"><path d="M5.2 7.5a.75.75 0 0 1 1.06 0L10 11.2l3.7-3.7a.75.75 0 1 1 1.06 1.06l-4.23 4.24a.75.75 0 0 1-1.06 0L5.2 8.56a.75.75 0 0 1 0-1.06z"/></svg></summary><p class="mt-2 text-sm text-slate-600">To most of Europe and North America.</p></details>
</div>

02. Tailwind One-Open-at-a-Time FAQ

TailwindFAQExclusive

Give every details element the same name attribute and the browser keeps only one open at a time, an exclusive accordion with no JavaScript. In older browsers they simply open independently.

View code
<div class="grid w-full max-w-sm gap-2">
  <details name="twfq2" class="group rounded-xl bg-white p-4 shadow-sm ring-1 ring-slate-200 open:ring-2 open:ring-teal-600" open><summary class="flex cursor-pointer list-none items-center justify-between font-semibold text-slate-900 focus-visible:outline-none [&::-webkit-details-marker]:hidden">Is there a free trial?<span aria-hidden="true" class="text-teal-700 group-open:hidden">+</span><span aria-hidden="true" class="hidden text-teal-700 group-open:inline">−</span></summary><p class="mt-2 text-sm text-slate-600">Yes, 14 days with every feature.</p></details>
  <details name="twfq2" class="group rounded-xl bg-white p-4 shadow-sm ring-1 ring-slate-200 open:ring-2 open:ring-teal-600"><summary class="flex cursor-pointer list-none items-center justify-between font-semibold text-slate-900 focus-visible:outline-none [&::-webkit-details-marker]:hidden">Do I need a card?<span aria-hidden="true" class="text-teal-700 group-open:hidden">+</span><span aria-hidden="true" class="hidden text-teal-700 group-open:inline">−</span></summary><p class="mt-2 text-sm text-slate-600">No card is needed to start.</p></details>
  <details name="twfq2" class="group rounded-xl bg-white p-4 shadow-sm ring-1 ring-slate-200 open:ring-2 open:ring-teal-600"><summary class="flex cursor-pointer list-none items-center justify-between font-semibold text-slate-900 focus-visible:outline-none [&::-webkit-details-marker]:hidden">Can I cancel any time?<span aria-hidden="true" class="text-teal-700 group-open:hidden">+</span><span aria-hidden="true" class="hidden text-teal-700 group-open:inline">−</span></summary><p class="mt-2 text-sm text-slate-600">Yes, from your account page.</p></details>
</div>
details:has(summary:focus-visible) { outline: 2px solid #0f766e; outline-offset: 2px; }

03. Tailwind FAQ with Plus-to-Minus Icon

TailwindFAQIcon

Each question shows a plus drawn from two bars; opening it collapses the vertical bar with group-open:scale-y-0, leaving a minus. The icon is pure CSS and hidden from screen readers, which hear the open state from details.

View code
<div class="w-full max-w-sm divide-y divide-white/10 rounded-2xl bg-slate-800">
  <details class="group p-4"><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-300 [&::-webkit-details-marker]:hidden">What is a credit?<span aria-hidden="true" class="relative size-4 shrink-0"><span class="absolute inset-x-0 top-1/2 h-0.5 -translate-y-1/2 rounded bg-amber-300"></span><span class="absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 rounded bg-amber-300 transition-transform group-open:scale-y-0"></span></span></summary><p class="mt-2 text-sm text-slate-300">One credit is one finished export.</p></details>
  <details class="group p-4"><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-300 [&::-webkit-details-marker]:hidden">Do credits expire?<span aria-hidden="true" class="relative size-4 shrink-0"><span class="absolute inset-x-0 top-1/2 h-0.5 -translate-y-1/2 rounded bg-amber-300"></span><span class="absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 rounded bg-amber-300 transition-transform group-open:scale-y-0"></span></span></summary><p class="mt-2 text-sm text-slate-300">They roll over for twelve months.</p></details>
  <details class="group p-4"><summary class="flex cursor-pointer list-none items-center justify-between gap-3 rounded font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-300 [&::-webkit-details-marker]:hidden">Can I share credits?<span aria-hidden="true" class="relative size-4 shrink-0"><span class="absolute inset-x-0 top-1/2 h-0.5 -translate-y-1/2 rounded bg-amber-300"></span><span class="absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 rounded bg-amber-300 transition-transform group-open:scale-y-0"></span></span></summary><p class="mt-2 text-sm text-slate-300">Yes, across everyone on a team plan.</p></details>
</div>

04. Tailwind Animated FAQ Accordion

TailwindFAQAnimation

An accordion that animates its answers open with grid-template-rows, using buttons with aria-expanded and aria-controls. Closed answers are inert so they cannot be tabbed into while hidden.

View code
<div id="twfq4" class="w-full max-w-sm divide-y divide-slate-200 rounded-2xl bg-white shadow-sm ring-1 ring-slate-200">
  <div class="group p-4"><h3><button type="button" aria-expanded="false" aria-controls="twfq4a" class="flex w-full items-center justify-between gap-3 rounded text-left font-semibold text-slate-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-violet-600">Which file types work?<span aria-hidden="true" class="text-violet-700 transition-transform group-data-[open]:rotate-45">+</span></button></h3><div class="grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 group-data-[open]:grid-rows-[1fr] motion-reduce:transition-none"><div id="twfq4a" class="overflow-hidden"><p class="pt-2 text-sm text-slate-600">PDF, JPG, PNG and WebP up to 20 MB each.</p></div></div></div>
  <div class="group p-4"><h3><button type="button" aria-expanded="false" aria-controls="twfq4b" class="flex w-full items-center justify-between gap-3 rounded text-left font-semibold text-slate-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-violet-600">Where are my files kept?<span aria-hidden="true" class="text-violet-700 transition-transform group-data-[open]:rotate-45">+</span></button></h3><div class="grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 group-data-[open]:grid-rows-[1fr] motion-reduce:transition-none"><div id="twfq4b" class="overflow-hidden"><p class="pt-2 text-sm text-slate-600">In your account until you delete them.</p></div></div></div>
</div>
document.querySelectorAll('#twfq4 > .group').forEach(function (g) {
  var b = g.querySelector('button'), a = document.getElementById(b.getAttribute('aria-controls'));
  function set(open) { b.setAttribute('aria-expanded', open); a.inert = !open; if (open) g.dataset.open = ''; else delete g.dataset.open; }
  b.onclick = function () { set(b.getAttribute('aria-expanded') !== 'true'); };
  set(false);
});

06. Tailwind Numbered Dark FAQ

TailwindFAQDark

Numbered questions on a dark panel, where the open item gets a lighter background with open:bg-white/5. The numbers are decorative badges, hidden from screen readers so the question text reads cleanly.

View code
<div class="grid w-full max-w-sm gap-1 rounded-2xl bg-slate-900 p-2 ring-1 ring-white/10">
  <details class="group rounded-xl p-3 open:bg-white/5" open><summary class="flex cursor-pointer list-none items-start gap-3 rounded text-sm font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-300 [&::-webkit-details-marker]:hidden"><span aria-hidden="true" class="rounded bg-sky-400/15 px-1.5 font-mono text-xs leading-5 text-sky-300">01</span>Is my data encrypted?</summary><p class="ml-10 mt-2 text-sm text-slate-300">Yes, in transit and at rest.</p></details>
  <details class="group rounded-xl p-3 open:bg-white/5"><summary class="flex cursor-pointer list-none items-start gap-3 rounded text-sm font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-300 [&::-webkit-details-marker]:hidden"><span aria-hidden="true" class="rounded bg-sky-400/15 px-1.5 font-mono text-xs leading-5 text-sky-300">02</span>Can I export everything?</summary><p class="ml-10 mt-2 text-sm text-slate-300">Yes, as CSV or JSON at any time.</p></details>
  <details class="group rounded-xl p-3 open:bg-white/5"><summary class="flex cursor-pointer list-none items-start gap-3 rounded text-sm font-semibold text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-300 [&::-webkit-details-marker]:hidden"><span aria-hidden="true" class="rounded bg-sky-400/15 px-1.5 font-mono text-xs leading-5 text-sky-300">03</span>Who can see my projects?</summary><p class="ml-10 mt-2 text-sm text-slate-300">Only people you invite.</p></details>
</div>

About these Tailwind FAQ Accordions

details and summary first

Native details elements open and close with no JavaScript and are accessible by default; style the open state with group-open: and open:.

Remove the default marker

list-none and [&::-webkit-details-marker]:hidden remove the triangle so you can draw your own icon.

Exclusive accordions

Give every details element the same name attribute and the browser closes the others when one opens.

Animated height

Animate grid-template-rows from [0fr] to [1fr] with button toggles, and make closed answers inert.

Frequently asked questions

Should I add FAQ schema?

Add FAQPage structured data only if the page is genuinely a list of questions and answers.

Can details animate?

Not smoothly on its own yet; the animated demo uses buttons for that reason.

Is there a CSS version?

Yes, see the CSS FAQ accordions collection.