Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Search Input

ProNew

A search field with a clear button, a debounced callback, a loading state and a focus shortcut.

Installation

pnpm dlx shadcn@latest add @viewport/search-input

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
valuestring—
defaultValuestring""
onSearch(query: string) => void

Runs once typing pauses, and immediately when the field is cleared.

—
debouncenumber

Milliseconds of quiet before `onSearch` runs.

250
loadingboolean

Replaces the search icon with a spinner while results load.

false
shortcutstring

A single key that focuses the field from anywhere on the page, e.g. "/". Shown as a hint while the field is empty.

—

Accessibility

  • A native search input with an accessible name.
  • Escape clears the field first, then lets the key through to a surrounding dialog.
  • The shortcut is ignored while you type in another field.
  • Respects prefers-reduced-motion.