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
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text and sample pages. |
sections | Array<{ id, name }> | sample sections | The sections results are grouped by, in order. A section with no result is left out. |
items | Array<{ id, section, title, text }> | sample pages | The pages to search. An empty array shows the empty state. |
defaultQuery | string | '' | Text the search starts with. |
filter | boolean | true | Narrow the items by the query in the browser. Pass false when the server already answered the query. |
loading / error | boolean / boolean | string | false | Show 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. |
labels | object | — | 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.