Rime

NavSearch and SmartSearch

Top-bar search: NavSearch jumps to pages and actions; SmartSearch queries records with grouped results.

NavSearch filters a fixed list of destinations with a keyboard shortcut (Ctrl or Cmd K). SmartSearch takes an async search function with abort signals and renders grouped record results with highlighting.

Installation

npx shadcn@latest add KezLahd/rime/nav-search

Also installs: base, icon, search-field.

Usage

import { NavSearch, SmartSearch } from "@/components/ui";

<NavSearch aria-label="Search pages" items={DESTINATIONS} />

Examples

Open

inline shows the results panel open under the bar, in place.

NavSearch

API

Generated from the component's TypeScript types and JSDoc (scripts/gen-ui-registry.mjs), so it always matches the source.

NavSearch

NavSearch props
PropTypeDefaultDescription
itemsRequiredReadonlyArray<NavSearchItem>
recentReadonlyArray<string>Ids of recently opened items, newest first. Listed under "Recent" above everything else while the search is empty. The host keeps the list (from onSelect), so it can live wherever the rest of the session does.
onSelect(item: NavSearchItem) => boolean | voidRuns before navigating. Return false to stay put (the styleguide does, and a host can to open a dialog instead).
placeholderstring"Search pages and actions"
shortcutstring | null"k"Ctrl/⌘ + this letter opens the search from anywhere. Pass null to turn it off.
widthnumber | string340Width of the bar, and the least width of its results.
aria-labelstringNames the search for assistive tech.
classNamestring
inlinebooleanfalseShow the results panel open, in place under the bar: no portal, no outside-click listener, no scrolling into view. For docs and thumbnails.

SmartSearch

SmartSearch props
PropTypeDefaultDescription
searchRequired(query: string, signal: AbortSignal) => Promise<SmartSearchGroup[]>Runs the search. Called once typing pauses, with a signal that aborts when the query changes, so a slow answer to "ha" never lands on top of "cooper". Reject (anything but an AbortError) to show the error state.
onSelectRequired(result: SmartSearchResult, context: SmartSearchSelectContext) => boolean | voidA result was chosen (Enter or click). The host records it in recent searches. Return false to stay put; otherwise a result with an href is navigated to.
onViewAll(query: string) => void"View all results": the footer row, and Enter with no row highlighted. Omit to leave both out.
recentReadonlyArray<string>Earlier queries, newest first. Offered while the field is focused and empty.
placeholderstring"Search"
minCharsnumber2Characters before a search runs. Defaults to 2: one letter matches most of a database.
debounceMsnumber180Pause after the last keystroke before searching.
renderResult(result: SmartSearchResult, state: SmartSearchResultState) => ReactNodeReplaces the default row body (tile, text, meta, hint are all yours).
emptyHintReactNodeShown when focused and empty with no recent searches: say what can be searched for.
noResultsHint(query: string) => ReactNodeSuggestion under "No results for …".
size"sm" | "md""md"
shortcutstringCtrl/⌘ + this letter focuses the field. Use once per page.
disabledboolean
idstring
aria-labelstringNeeded unless a <Field> labels it.
classNamestring

Theme tokens

Per-component tokens are undeclared by default, so the default shown is the fallback the CSS uses. Set one at :root (or in theme.css) to restyle every instance. Live values are read from this page, so they follow the Rime Studio.

This component has no tokens of its own; it reads the system tokens below.

System tokens it reads

NavSearch and SmartSearch system tokens
TokenDefaultLive value
--blur-chrometokens.css…
--brand-gradienttokens.css…
--brand-gradient-softtokens.css…
--danger-inktokens.css…
--durtokens.css…
--dur-fasttokens.css…
--easetokens.css…
--ease-outtokens.css…
--focus-halotokens.css…
--focus-ringtokens.css…
--font-bodytokens.css…
--glass-edgetokens.css…
--glass-fill-chrometokens.css…
--glow-smtokens.css…
--ink-bodytokens.css…
--ink-brandtokens.css…
--ink-headingtokens.css…
--ink-inversetokens.css…
--ink-mutedtokens.css…
--ink-secondarytokens.css…
--linetokens.css…
--line-brandtokens.css…
--line-brand-strongtokens.css…
--line-softtokens.css…
--r-2xstokens.css…
--r-fulltokens.css…
--r-lgtokens.css…
--r-mdtokens.css…
--r-smtokens.css…
--rgb-brand-deeptokens.css…
--rgb-whitetokens.css…
--shadow-chrometokens.css…
--shadow-chrome-opentokens.css…
--shadow-floattokens.css…
--surface-solidtokens.css…
--text-captiontokens.css…
--text-microtokens.css…
--text-smalltokens.css…
--tracking-labeltokens.css…
--wash-activetokens.css…
--wash-hovertokens.css…
--wash-rowtokens.css…
--wash-strongtokens.css…
--wash-subtletokens.css…
--z-popovertokens.css…

Accessibility

  • Combobox with a listbox of results; the shortcut is announced in the hint.

Do and don't

Do

  • Keep NavSearch items to real destinations.

Don't

  • Don't use SmartSearch without debouncing on the server side too.

For AI agents

This page as markdown, rendered from the same registry entry. Point an agent at it (or add .md to this page's URL), or at /llms.txt for the index.

Open nav-search.md