Xzero UI
Pro library

Search resultsPro

A faceted workspace search page with suggestions, facet counts that follow the query, filter chips, mixed doc, person and file results with highlighted matches, a gliding keyboard cursor and a preview pane.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/search-results
Live · keyboard ready

Render <SearchResults /> for the demo, or pass results (docs, people, files), teams, recentSearches and suggestedSearches, with onSearch and onOpen to wire it to a real index. Set latency={0} and swap results yourself when your fetch resolves.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/search-results

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { SearchResults } from "@/components/xzero/blocks/search-results/search-results";

export function WorkspaceSearch({ items }: { items: SearchResult[] }) {
  return (
    <SearchResults
      results={items}
      workspace="Acme"
      defaultQuery=""
      latency={0}
      onSearch={query => track("search", { query })}
      onOpen={result => router.push(`/${result.kind}/${result.id}`)}
    />
  );
}

API reference

SearchResults

A faceted search results page for a workspace. A query bar with recent and suggested searches, a facet sidebar whose counts follow the query, a last edited range, active filter chips, and one list of mixed docs, people, and files with every match highlighted. A keyboard cursor glides through the results and a preview pane follows it.

PropTypeDefaultDescription
resultsSearchResult[]sample workspaceEverything that can be found. Each item is a doc ({ title, path, snippet, body, author, updated, readMinutes }), a person ({ person, title, role, snippet, email, location, owns }), or a file ({ title, ext, size, snippet, owner, updated, photo?, pages? }), all with an id and a team.
teamsSearchTeam[]teamsTeam facet options ({ id, label }) in display order.
recentSearchesstring[]–Recent queries shown first in the suggestions. Runs are added to the front, up to five.
suggestedSearchesstring[]–Suggested queries shown under recent ones and offered again when nothing matches.
defaultQuerystring"onboarding"Query shown and run on first render.
defaultSort"relevance" | "newest" | "title""relevance"Initial sort: best match, newest first, or A to Z.
todaystring"2026-09-24"ISO day that relative dates and the edited range are measured from, so the server and client render the same labels.
workspacestring"Northwind"Workspace name used in the placeholder and the region label.
latencynumber650Simulated query time in milliseconds while skeletons show. 0 shows results at once.
onSearch(query: string) => void–Called each time a query runs, from Enter, a suggestion, a spelling fix, or an empty state suggestion.
onOpen(result: SearchResult) => void–Called when the preview's primary action (Open doc, View profile, Download) completes.
classNamestring–Class on the root section.

Keyboard interactions

KeysAction
/Focuses the query from anywhere on the page, unless another field has focus.
Arrow down / Arrow up in the queryMoves through recent and suggested searches; with the list closed, Arrow down moves into the results.
Enter in the queryRuns the highlighted suggestion or the typed query.
Escape in the queryCloses the suggestions, then clears the text.
Arrow down / Arrow up, J / KMoves the result cursor; Arrow up on the first result returns to the query.
Home / EndJumps to the first or last result.
Enter / Space on a resultOpens it: the preview pane follows on wide layouts, and a sheet opens on narrow ones.
Escape in the resultsReturns focus to the query.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components