Rime

SearchField

Field-size search on the grey frosted recess: clear button, loading state and an optional key hint.

SearchField is the search box on a page (not in a filter row, where FilterSearch lives). It lifts toward white while focused, shows a clear button once there is a query, and can show a shortcut hint ("/") that focuses it from anywhere.

Installation

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

Also installs: base, field, icon, spinner.

Usage

import { SearchField } from "@/components/ui";

<SearchField aria-label="Search invoices" value={q} onValueChange={setQ} placeholder="Customer or invoice number" />

Examples

Default, loading

Searching…

API

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

SearchField

SearchField props
PropTypeDefaultDescription
valueRequiredstring
onValueChangeRequired(value: string) => void
size"sm" | "md""md"md sits level with TextInput and Select; sm with the 36px controls.
loadingbooleanfalseResults are being fetched. The magnifier turns into a spinner and the field reports busy.
loadingLabelstring"Searching…"Announced while loading.
shortcutstringA letter that focuses the field with Ctrl/⌘. Shows as a key badge while the field is empty and unfocused. Use once per page.
onSearch(value: string) => voidEnter runs this (and never submits an enclosing form). Omit for live filtering.
invalidboolean
boxClassNamestringClass for the outer box rather than the <input>.

Also accepts the native attributes of AriaAttributes, DOMAttributes, HTMLAttributes, InputHTMLAttributes.

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.

SearchField per-component tokens
TokenDefaultLive value
--field-focus-borderrgba(var(--rgb-brand), 0.7)…
--field-focus-ringvar(--focus-halo)…
--field-focus-ring-invalid0 0 0 4px rgba(var(--rgb-danger), 0.14)…
--input-border-widthvar(--border-w-field)…
--input-font-sizevar(--text-input)…
--input-height-mdvar(--field-h-md)…
--input-height-smvar(--field-h-sm)…
--input-radiusvar(--r-md) / var(--r-sm)…

System tokens it reads

SearchField system tokens
TokenDefaultLive value
--blur-recesstokens.css…
--border-w-fieldtokens.css…
--danger-basetokens.css…
--densitytokens.css…
--durtokens.css…
--easetokens.css…
--field-h-mdtokens.css…
--field-h-smtokens.css…
--focus-halotokens.css…
--focus-ringtokens.css…
--font-bodytokens.css…
--ink-bodytokens.css…
--ink-brandtokens.css…
--ink-disabledtokens.css…
--ink-mutedtokens.css…
--r-2xstokens.css…
--r-mdtokens.css…
--r-smtokens.css…
--r-xstokens.css…
--recess-filltokens.css…
--recess-fill-hovertokens.css…
--rgb-brandtokens.css…
--rgb-brand-deeptokens.css…
--rgb-dangertokens.css…
--rgb-whitetokens.css…
--shadow-recesstokens.css…
--text-bodytokens.css…
--text-inputtokens.css…
--text-microtokens.css…
--wash-activetokens.css…
--wash-strongtokens.css…

Accessibility

  • Renders input type="search". Esc clears the query and stops there, so an enclosing modal stays open; a second Esc on an empty field bubbles. The clear button returns focus to the input.
  • Give it an aria-label or a Field label.

Do and don't

Do

  • Debounce the query yourself; the field reports every keystroke.

Don't

  • Don't use it inside a FilterBar; use FilterSearch there so heights match.

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 search-field.md