Searchable FAQ
ComponentsSearchable FAQ
SectionsNew

Searchable FAQ

Filter questions by search or category, then expand an answer.

React + CSS
Explore the full-width experienceOpen preview

Customer support

4 questions

Orders dispatch within two working days. Standard delivery takes another three to five working days.

Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/searchable-faq.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { SearchableFAQ } from '@/components/anticraft/SearchableFAQ';

export function Example() {
  return <SearchableFAQ
    title="Customer support"
    items={[
      { id: 'shipping', category: 'Orders', question: 'When will my order arrive?', answer: 'Orders dispatch within two working days. Standard delivery takes another three to five working days.', keywords: ['delivery'] },
      { id: 'returns', category: 'Returns', question: 'Can I return an item?', answer: 'Unused items can be returned within 30 days.' },
    ]}
  />;
}
03

Props

PropTypeDefaultDescription
itemsSearchableFAQItem[]RequiredUnique id, question and plain-text answer; optional category and keywords. Search matches question, answer and keywords without case sensitivity. Newlines in answers are preserved.
titlestring'Questions & answers'Section heading. An empty string hides it while preserving the accessible section name.
searchPlaceholderstring'Search questions…'Placeholder text. The input retains a separate accessible label.
defaultOpenIdstringundefinedInitially expanded question. Unknown or removed ids show no open answer. At most one question is open.
onOpenChange(id: string | null) => voidundefinedCalled for a question toggle or when filtering closes an open answer. Data changes do not notify. Use a Client Component to supply this callback in Next.js.
classNamestring''Additional classes. Customize --ac-faq-ink, --ac-faq-muted, --ac-faq-line, --ac-faq-surface and --ac-faq-accent.
04

Motion & accessibility

Considered by default.

Tab reaches search, category filters and question buttons. Enter or Space toggles an answer; Up/Down and Home/End move between visible question buttons. Filtering closes the open answer and announces the result count. Reduced motion removes entry and icon transitions.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.