shadcn.io is not affiliated with official shadcn/ui
Categorized FAQ Block for React
A topic-tabbed FAQ for a bookkeeping app: a compact header, a band of line tabs with a count on each, and one accordion per topic.
Installation
Overview
A categorized FAQ for React with Base UI. Under a compact header, a band of line tabs names five topics, each with a small count of its questions; choosing a tab swaps in that topic's accordion of hairline rows, the first row open, and a contact line closes the block. The tab list scrolls sideways on a phone behind a fade at its end, and every panel shares one minimum height, so switching topics never moves the page below. The page's rails and top rule come from the Guides spine, and the tab band draws its own rule with + marks. It's built from Tabs, Accordion, Badge, Guides and Button, with CSS transitions for the entrance and your theme's tokens for every colour. For product pages and help centres whose questions fall into a handful of topics.
FAQ
How do I change the topics and questions?
Edit TOPICS at the top of the file: each topic has an id, a label and its questions (an id, the question and its answer, one to three sentences). The count on each tab is the length of that list, so it never drifts, and the first question of every topic opens when its tab does. Keep it to about five topics and four questions each: more than that wants a search.
How does it work with a keyboard and a screen reader?
The tabs are a real tab list named "FAQ topics": the arrow keys move between them (mirrored in a right-to-left layout), Home and End jump to the first and last, and Tab moves on into the open panel. Each question is a button inside its own h3 under the section's h2, and Enter or Space opens it.
Focusing a tab selects it, as on the other libraries; inside a panel, Tab moves from question to question.
Are the answers of the other topics in the page's markup?
Yes, the panels of the topics you aren't looking at stay in the page, hidden.
Each panel takes keepMounted, and each Accordion hiddenUntilFound, so a closed answer stays in the markup and the browser's find in page opens it.
Why doesn't the page move when I switch tabs?
Every panel has the same minimum height, about the tallest topic with its first answer open, so a shorter topic leaves quiet space under its rows instead of pulling the contact line up. Opening more answers in a panel still grows it, as any accordion does.
Related
- Pro
Tabbed Vertical FAQ
NavigationA vertical-tabs FAQ for a transit app: a rail of five topics with an icon and a count each, beside the open topic's accordion, behind a split divider.
- Pro
Collapsible Sidebar FAQ
NavigationA sidebar FAQ for a holiday-rental site: a topic rail with two collapsible groups and a live count, beside a filtered list, and a native select on phones.
- Pro
Topic Select FAQ
Topics and filtersA short FAQ for a bike-share with a topic Select at the end of its header: choose a topic and its questions fill the rows below, or choose All topics for all twelve.
- Pro
Multi Select FAQ
Topics and filtersA topic-chip FAQ for an outdoor-gear rental: any number of chips can be on, and the list shows the union of their questions, with a live count.
- Pro
Expandable Sections FAQ
Accordion listsA two-level FAQ for a photo-book shop: an accordion of three sections whose panels each hold an accordion of questions, with a summary of how many of each.
- Pro
Sortable FAQ
Topics and filtersA FAQ for a garden-planner app whose questions really sort: a three-way control in a narrow start column reorders eight rows by most asked, newest or A to Z.