Staaarter

Live Search FAQ

An FAQ with a search field that narrows the list as it is typed, matching against topic, question, and answer, with every answer open on its own hairline row and an empty state when nothing matches.

By Staaarter Team
FAQ
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its input, label dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/live-search-faq.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/faq/faq85.tsx instead.

Usage

The file also exports faq85Demo, 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 { Faq85, faq85Demo } from "@/components/blocks/faq/faq85";

export default function Page() {
  return <Faq85 {...faq85Demo} />;
}

Props

PropTypeDefaultDescription
badgestringnoneSmall eyebrow label above the heading.
headingstringnoneSection heading.
descriptionstringnoneSection intro text.
searchPlaceholderstring"Search questions..."Placeholder text on the search input.
entriesFaqEntry[]noneFull FAQ list; the search input filters this array by topic, question, and answer.
classNamestringnoneExtra classes for the outer section element.

Types

type FaqEntry = {
  topic: string;
  question: string;
  answer: string;
};

Behavior notes

  • "use client" because the search input is a real controlled field: typing filters the visible entries via local state and a useMemo derivation, case-insensitively, across the topic, question, and answer fields.
  • Every matching entry renders fully expanded on its own hairline row; there is no accordion collapse here, the search itself is the narrowing mechanism.
  • An empty state message renders in place of the list when the query matches zero entries.