Topic Rail FAQ
A categorised FAQ whose topic rail is derived from the questions themselves and carries a live count badge per topic. Clicking a topic switches the accordion beside it to that topic's questions and resets which item is expanded back to the first one.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/topic-rail-faq.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/faq/faq82.tsx instead.
Usage
The file also exports faq82Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Faq82, faq82Demo } from "@/components/blocks/faq/faq82"; export default function Page() { return <Faq82 {...faq82Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| eyebrow | string | "FAQ" | Small label above the heading. |
| heading | string | "Find your answer by topic" | Section heading. |
| description | string | none | Supporting copy under the heading. |
| items | FaqItem[] | none | Flat list of question/answer items, each tagged with a topic string; the topic rail and its counts are computed from this list. |
| className | string | none | Extra classes for the outer section element. |
Types
type FaqItem = { topic: string; question: string; answer: string; };
Behavior notes
- The topic rail and its count badges are computed with useMemo from the items prop; there is no separate topics list to pass in, so a typo in an item's topic string creates a new rail entry.
- The first topic in items' natural order is selected by default via a lazy useState initializer (not a mount-time effect), keeping the block hydration-safe.
- Clicking a topic filters the accordion list to that topic's items and resets the open accordion index back to 0, so the previous topic's expanded state never leaks into the new one.
- The accordion on the right allows only one item open at a time; clicking the currently open item collapses it.
- This is a real 'use client' component; demo props live in the separate faq82.demo.tsx file so the live block preview (rendered from a Server Component) receives real data instead of undefined.
More FAQ Blocks
View all →collapsible-accordion
Collapsible Accordion
Stacked cards with expandable sections, for full-length answers in a compact format.
open-list-layout
Open List Layout
Questions with answers displayed directly below in a simple always-open list.
three-column-grid
Three Column Grid
Q&A pairs arranged in a responsive grid layout, always open.
tabbed-categories
Tabbed Categories
Sidebar navigation with category tabs and an accordion of that category's questions.
searchable-accordion
Searchable Accordion
Search input that filters accordion items in real-time by question and answer text.
grouped-sections
Grouped Sections
FAQs organized into titled sections, each with its own independent accordion below it.