Skip to content
English

Usage

import { DocsSearch } from './DocsSearch.jsx'

// Fetch from your search route as the visitor types, and open the page they choose:
<DocsSearch
  locale="en"
  sections={[{ id: 'guides', name: 'Guides' }]}
  items={results}              // [{ id, section, title, text }]
  filter={false}               // the server already matched the query
  loading={!results}
  error={searchError}
  onRetry={reloadIndex}
  onSearch={(q) => setQuery(q)}
  onOpen={(page) => router.push('/docs/' + page.id)}
/>

Props

PropTypeDefaultWhat it does
locale'en' | 'zh-CN' | 'es' | 'ja''en'Language of the built-in text and sample pages.
sectionsArray<{ id, name }>sample sectionsThe sections results are grouped by, in order. A section with no result is left out.
itemsArray<{ id, section, title, text }>sample pagesThe pages to search. An empty array shows the empty state.
defaultQuerystring''Text the search starts with.
filterbooleantrueNarrow the items by the query in the browser. Pass false when the server already answered the query.
loading / errorboolean / boolean | stringfalseShow the skeleton, or the error banner with a retry button (a string replaces its sentence).
onSearch / onOpen / onRetry(query) => void / (item) => void / () => void—The search changed; a result was opened with a click or Enter; retry was pressed.
labelsobject—Replaces any built-in text (keys as in copy.js).

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.

DocsSearch.jsxdocs-search.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/kbd/ui/alert-banner/ui/text-input/ui/skeleton-shimmer/tokens.cssREADME.md

The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.