Accordion

Smooth FAQ accordion with plus/minus icons.

What is your return policy? +

You can return any item within 30 days of purchase for a full refund. No questions asked.

How long does shipping take? +

Standard shipping takes 3-5 business days. Express options are available at checkout.

Do you ship internationally? +

Yes, we ship to over 50 countries. Rates are calculated at checkout.

Tailwind CSS
<div class="w-full max-w-md space-y-2">
  <details class="rounded-2xl border border-slate-200 bg-white px-5 py-4 group">
    <summary class="flex items-center justify-between cursor-pointer font-semibold text-slate-900 text-sm list-none">
      What is your return policy?
      <span class="text-indigo-600 font-bold text-lg group-open:rotate-45 transition-transform">+</span>
    </summary>
    <p class="mt-3 text-sm text-slate-500 leading-relaxed">You can return any item within 30 days of purchase for a full refund. No questions asked.</p>
  </details>
  <details class="rounded-2xl border border-slate-200 bg-white px-5 py-4 group">
    <summary class="flex items-center justify-between cursor-pointer font-semibold text-slate-900 text-sm list-none">
      How long does shipping take?
      <span class="text-indigo-600 font-bold text-lg group-open:rotate-45 transition-transform">+</span>
    </summary>
    <p class="mt-3 text-sm text-slate-500 leading-relaxed">Standard shipping takes 3-5 business days. Express options are available at checkout.</p>
  </details>
  <details class="rounded-2xl border border-slate-200 bg-white px-5 py-4 group">
    <summary class="flex items-center justify-between cursor-pointer font-semibold text-slate-900 text-sm list-none">
      Do you ship internationally?
      <span class="text-indigo-600 font-bold text-lg group-open:rotate-45 transition-transform">+</span>
    </summary>
    <p class="mt-3 text-sm text-slate-500 leading-relaxed">Yes, we ship to over 50 countries. Rates are calculated at checkout.</p>
  </details>
</div>

Free to use in personal and commercial projects. No attribution required.

About this accordion

Accordions are the workhorse of FAQ sections, product details, and settings pages. They let visitors expand one section at a time without scrolling through walls of text. A css accordion built on the native details element needs zero JavaScript: the browser handles open and close, keyboard access, and even the open state.

This tailwind accordion uses details and summary with the group-open variant to rotate the plus icon. The list-none class removes the default disclosure triangle so your custom icon is the only indicator. It is accessible out of the box because details/summary are natively keyboard-operable.

One limitation: native details elements do not animate the height transition smoothly in most browsers. If you need buttery expand/collapse animation, you will need a JavaScript solution with grid-template-rows or max-height transitions. For most FAQ sections, the instant toggle is perfectly fine.

FAQ sections and product details face a space problem: show every answer and the page becomes an endless scroll; show none and questions go unanswered. The accordion compresses N answers into N headlines, letting visitors expand only what they need. It respects the reader's time by making the page scannable first and detailed on demand.

This element uses the native details and summary elements, so the browser handles the toggle, keyboard access, and open state with zero JavaScript. The summary gets list-none to remove the default disclosure triangle and cursor-pointer for affordance. The plus icon rotates with group-open:rotate-45, turning the + into an x when open. The answer is a plain paragraph inside, styled for comfortable reading.

For single-open behavior where expanding one closes the others, add a tiny script that closes sibling details on toggle. Give the expanded item a subtle background tint via the open variant so readers can spot which section is open at a glance. Keep the first item open by default with the open attribute; it gives immediate value and teaches the pattern without explanation.

The interaction mistake is placing links or buttons inside the summary element, where clicking them also toggles the accordion and users trigger the wrong action. Summaries should contain only text and the icon. Put every interactive element in the expanded content, where clicks do exactly what they promise.

Design notes

When to use

Use it for FAQ sections, product detail expanders, and settings panels where visitors open one section at a time. Built on native details and summary, it needs no JavaScript and the browser handles keyboard access. It keeps long pages scannable.

What to avoid

Do not bury critical content that every visitor must see inside a closed accordion. Do not nest accordions several levels deep; deep nesting confuses navigation and breaks the scan pattern.

Accessibility

Details and summary are natively keyboard operable, which is the main reason to prefer them. Keep a proper heading structure around the accordion and make sure the plus icon is decorative, not the only open indicator.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Dark

The dark accordion fits help centers inside dark-mode products.

How do I reset my password? +

Go to settings, choose Security, then click Reset password. The link expires in 15 minutes.

Can I change my plan later? +

Yes, upgrade or downgrade anytime. Changes apply from your next billing cycle.

Tailwind CSS

Numbered

Numbered items help when FAQs have a natural order, like setup steps.

01 How do I install the widget? +

Paste one script tag before the closing body tag. No build step needed.

02 Which frameworks are supported? +

React, Vue, Svelte, and plain HTML. The widget is framework agnostic.

Tailwind CSS

Minimal

The minimal style suits docs pages where accordions should stay quiet.

What is your refund policy? +

Full refunds within 14 days of purchase, no questions asked.

Do you offer support? +

Yes, email support with a 24 hour response time on all plans.

Tailwind CSS

Where to use it

  • ✓ FAQ sections
  • ✓ Product detail expanders
  • ✓ Settings panels
  • ✓ Mobile navigation menus

Frequently asked questions

How do I make an accordion with only CSS?

Use the native HTML details and summary elements. The browser handles toggling natively with no JavaScript. Style the open state with the open: variant and rotate icons with group-open:

Can accordions animate smoothly?

Native details elements toggle instantly in most browsers. For smooth height animation, use a JavaScript approach with grid-template-rows: 0fr to 1fr transitions.

Should only one accordion item be open at a time?

For FAQs, single-open (exclusive) feels cleaner. For settings or product details, multiple-open is fine. Native details allows multiple open; exclusive needs JavaScript.

How do I rotate the accordion icon when it opens?

Put a transition on the icon's transform, then rotate it 180 degrees when the item is open. With native details elements use details[open] summary .icon as the selector. With a JS accordion, toggle an open class on the item and target .open .icon.

How do I keep the first accordion item open by default?

Add the open attribute to the first <details> element and it renders expanded with no JavaScript. For checkbox-based accordions, add the checked attribute to the first input. For JS accordions, call your open function on the first item during initialization.

Can I build an accordion with details and summary?

Yes, and it is the most accessible option because keyboard handling and semantics come free. Style the summary as the clickable header and hide the default marker to use your own icon. For smooth height animation, pair it with the grid-template-rows 0fr to 1fr trick on the content wrapper.

Customization tips

Swap the plus for a chevron that rotates 180 degrees with group-open:rotate-180. For single-open behavior (closing others when one opens), add a tiny script or use radio inputs. Style the open state with open:bg-slate-50.