Skip to content

FAQ Accordion Section

Dark Tailwind CSS FAQ section with an accessible accordion, smooth expand animation, keyboard navigation and a support contact card.

Also known as: faq accordion, frequently asked questions section, expandable questions, help center faq

Tailwind CSS FAQ Sections Responsive Dark #accessible #accordion #collapse #dark #faq

FAQ Accordion Section live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A dark FAQ section built with Tailwind CSS and a small vanilla JavaScript controller: an intro column with a "Still have questions?" support card on the left and an accordion of expandable answers on the right. Answers slide open smoothly, only one stays open at a time, and the pattern follows the WAI-ARIA accordion guidance, which makes it a solid fit for pricing pages, help centers and product landing pages.

How it works

The root is section.tfa-faq on a bg-zinc-950 background. From the lg breakpoint a two-column grid places the intro column (sticky while you scroll) next to .tfa-list; on phones the columns stack.

Each question is a .tfa-item containing an h3 with a button.tfa-trigger and a .tfa-panel answer region. The button has aria-expanded and aria-controls, and the panel has role="region" with aria-labelledby pointing back to the button. The round .tfa-icon shows a plus sign; its .tfa-bar stroke rotates 90 degrees to form a minus, and group-data-[open]: classes fill the circle with sky blue on the open item.

On DOMContentLoaded the script initializes every .tfa-faq, syncs the data-open attribute on each item with its aria-expanded value and then sets data-tfa-ready on the root. Only then does style.css collapse the panels, animating grid-template-rows from 0fr to 1fr so answers of any length open smoothly without measuring heights. Closed panels also get visibility: hidden, which keeps their content out of the tab order and the accessibility tree. Clicking a question toggles it; because the root has data-tfa-single, opening one closes the others. Without JavaScript every answer is shown and the icons are hidden.

Customization

  • Remove data-tfa-single from .tfa-faq to let several answers stay open at once.
  • Set aria-expanded="true" on a different .tfa-trigger (and data-open on its .tfa-item) to open another question by default, or set all to false.
  • 0.3s in the grid-template-rows transitions in style.css: speed up or slow down the open animation.
  • text-sky-400, bg-sky-400 and group-data-[open]:bg-sky-400: replace sky with violet or amber for a new accent.
  • lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] on the inner grid: remove it and the intro column for a single centered accordion.
  • Duplicate a .tfa-item to add questions, giving its button and panel new id values such as tfa-q7 and tfa-a7.

Use cases

  • Pricing pages: answers slide open one at a time to address common questions
  • Help centers: a Still have questions support card points visitors to contact options
  • Product landing pages: a dark intro column sits beside an accordion of answers
  • Accessible sites: keyboard navigation follows the WAI-ARIA accordion pattern for assistive technology users

Accessibility

Questions are real buttons inside headings, so they work with Enter and Space and appear in heading navigation. aria-expanded announces the state, and each answer region is labelled by its question. Arrow Up and Arrow Down move focus between questions, while Home and End jump to the first and last. Focus rings use focus-visible:outline-sky-400. Decorative icons are aria-hidden. Under prefers-reduced-motion: reduce all transitions are removed and panels open instantly. Zinc and sky text on zinc-950 meets WCAG AA contrast.

Usage notes

Several FAQ blocks can share a page; give each copy unique id values for headings, buttons and panels.

FAQ Accordion Section at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile, dark design
Category
FAQ Sections
License
Free for personal and commercial use

Questions about this template

Can I use the FAQ Accordion Section code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

FAQ Accordion Section – free Tailwind CSS faq section template
FAQ Accordion Section · free Tailwind CSS faq section template

More FAQ Sections

Two-Column FAQ – free Bootstrap 5 faq section template

Two-Column FAQ

Bootstrap 5 FAQ section with questions split into two accordion columns, plus/minus icons and a dark contact support prompt.

FAQ Accordion with Details Blocks – free WordPress faq section template

FAQ Accordion with Details Blocks

An FAQ accordion with six expandable questions next to a heading and contact button, a frequently asked questions section built from Gutenberg Details blocks.

FAQ Accordion Section for Shopify – free Shopify faq section template

FAQ Accordion Section for Shopify

Shopify FAQ section with a native details accordion, an intro column with contact button, and optional FAQPage structured data.

FAQ with Category Tabs – free Bootstrap 5 faq section template

FAQ with Category Tabs

Bootstrap 5 FAQ section where category pills switch between separate accordion sets, with question counts and a support card.

FAQ with Live Search Filter – free Tailwind CSS faq section template

FAQ with Live Search Filter

Tailwind CSS FAQ section with a live search box that filters questions as you type, highlights matches, adds topic chips and shows an empty state.