A search results page: the query, how many results and how fast, facets by type with counts, highlighted matches with breadcrumbs, keyboard moves, suggestions when nothing matches, and pages.
Used for
- Docs search page
- Site-wide search
- Faceted results
- No-results suggestions
Examples
Installation
npx knowns-ui@latest add search-resultsFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Search results from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/search-results
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add search-results
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/code-block/code-block.tsx
- components/ui/knowns/code-block/code-block-utils.ts
- components/ui/knowns/blocks/content/prose.tsx
- components/ui/knowns/blocks/content/content-utils.ts
- components/ui/knowns/kbd.tsx
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/input.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- components/ui/knowns/select.tsx
- components/ui/knowns/pagination.tsx
- components/ui/knowns/toggle-group.tsx
- components/ui/knowns/blocks/content/search-results.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/search-results, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "search-results" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- query / onQueryChange
string / (q) => void- The search box (controlled).
- results
SearchResult[]- { id, type, title, excerpt?, href?, crumbs? }, best first. Matches of the query are highlighted; long excerpts are cut around the first match.
- types
{ value, label }[]- Default
docs, blog, changelog - Facets, with counts.
- type / onTypeChange
string- Default
"all" - The facet (controlled or not).
- timeMs / loading
number / boolean- For “12 results in 18 ms”, or Searching…
- pageSize
number- Default
8 - Results per page.
- suggestions
string[]- Default
[] - Offered when nothing matches.
- onSelect
(result) => void- For results without href, or to track clicks.
| Prop | Type | Default | Description |
|---|---|---|---|
| query / onQueryChange | string / (q) => void | - | The search box (controlled). |
| results | SearchResult[] | - | { id, type, title, excerpt?, href?, crumbs? }, best first. Matches of the query are highlighted; long excerpts are cut around the first match. |
| types | { value, label }[] | docs, blog, changelog | Facets, with counts. |
| type / onTypeChange | string | "all" | The facet (controlled or not). |
| timeMs / loading | number / boolean | - | For “12 results in 18 ms”, or Searching… |
| pageSize | number | 8 | Results per page. |
| suggestions | string[] | [] | Offered when nothing matches. |
| onSelect | (result) => void | - | For results without href, or to track clicks. |
- Down Arrow in the search box moves to the first result; Up and Down move between results, Up from the first goes back to the box, and Esc returns to it.
- The result count is announced as it changes. Matches use mark elements.
What it handles
- 01Renders a controlled query box, with query and onQueryChange, and a results list you pass in, best match first.
- 02Prints a status line such as "12 results in 18 ms" from timeMs, or Searching when loading is set, as a live region.
- 03Adds type facets for docs, blog and changelog with their counts, and disables a facet that has no results.
- 04Highlights matches in the title and in an excerpt cut to a window around the first match, and shows crumbs like Docs > Agents above each title.
- 05Moves by keyboard: Down from the box into the list, Up and Down between results, and Escape back to the box.
- 06Shows suggestions as chips when nothing matches, and pages the results with Pagination at the pageSize of 8.
States
- First render
- Nothing. The box paints with a hint line before any query
- none
- Typing
- The list, facets and count update at once and the page resets to 1
- none
- Result hover or focus
- The row background shifts
- 120ms, ease out
- Suggestion chip hover
- The chip background shifts
- 120ms, ease out
- Reduced motion
- Colour changes land at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The box paints with a hint line before any query | none |
| Typing | The list, facets and count update at once and the page resets to 1 | none |
| Result hover or focus | The row background shifts | 120ms, ease out |
| Suggestion chip hover | The chip background shifts | 120ms, ease out |
| Reduced motion | Colour changes land at once | 0ms |
Works with
When to use
When to use
- A full search page across docs, blog and changelog, with facets and pages.
- Showing why each result matched, with highlights and breadcrumbs.
When not to use
- Quick jumps from anywhere with the keyboard: use Command Menu.
- Picking one value in a form: use Combobox.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Search Results to my app and wire it to my own data.
- I need a full search page across docs, blog and changelog, with facets and pages. Set that up with the Knowns UI Search Results.
- Which Search Results props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "search-results" }) and search_docs({ query: "search results" }).