Staaarter

Search with Grid

A labeled search input filters the FAQ list live as the visitor types, matching substrings in either the question or the answer, case-insensitively. Matches render in a two-column card grid, with a friendly 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 badge dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/search-with-grid.json

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

Usage

The file also exports faq22Demo, 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 { Faq22, faq22Demo } from "@/components/blocks/faq/faq22";

export default function Page() {
  return <Faq22 {...faq22Demo} />;
}

Props

PropTypeDefaultDescription
badgestringnoneSmall label shown above the heading.
headingstringnoneSection heading.
descriptionstringnoneSupporting copy under the heading.
faqsFaqItem[]noneFull list of question/answer pairs searched against.
classNamestringnoneExtra classes for the outer section element.

Types

interface FaqItem {
  question: string;
  answer: string;
}

Behavior notes

  • Real controlled search: the input's value drives a useMemo filter over the faqs array, matching a case-insensitive substring against both the question and the answer text on every keystroke.
  • When the filtered result set is empty, an empty state message echoes the current search term back to the visitor.
  • The search input has no debounce, filtering runs synchronously on each keystroke since the dataset is small.