Skip to content

Search Results

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.

On this page
Used for
  • Docs search page
  • Site-wide search
  • Faceted results
  • No-results suggestions

Examples

Installation

npx knowns-ui@latest add search-results
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

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 }[]
Defaultdocs, 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
Default8
Results per page.
suggestions
string[]
Default[]
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

  1. 01Renders a controlled query box, with query and onQueryChange, and a results list you pass in, best match first.
  2. 02Prints a status line such as "12 results in 18 ms" from timeMs, or Searching when loading is set, as a live region.
  3. 03Adds type facets for docs, blog and changelog with their counts, and disables a facet that has no results.
  4. 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.
  5. 05Moves by keyboard: Down from the box into the list, Up and Down between results, and Escape back to the box.
  6. 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

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" }).

Need help?

Stuck on Search Results, or found something off? We read every message.