Prodular UI

Search input

A search field with a clear button, a global keyboard shortcut, a loading state and recent searches while it is empty.

npx prodular-ui add search-input

Recent searches

Focus the empty field to see them. Arrow keys move, Enter picks, Escape clears.

Press / anywhere to focus. Recent searches show while the field is empty.

Search as you type

The icon becomes a spinner while results load. Cmd or Ctrl and K focuses it.

  • Kestrel Health
  • Halden Health

Anatomy

<SearchInput  aria-label="Search invoices"  value={query}  onValueChange={setQuery}  onSearch={run}  shortcut="/"  recent={recent}/>

Guidance

Use it when

  • Searching a list, a table or the whole product.
  • shortcut on the one main search of a page, so keyboard users can reach it from anywhere.
  • recent when people repeat searches, like customer names or invoice numbers.

Avoid

  • Two inputs on one page with the same shortcut.
  • Picking a value for a form. Use Combobox, which keeps the choice.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Give it aria-label (or a visible label) that says what is searched, for example Search invoices.
  • Use onValueChange for search as you type, debounced, and set loading while the request is in flight.
  • Use onSearch for searches that run on Enter, and add the term to recent there.
  • Keep recent to five or fewer items, newest first, and offer onClearRecent.

API

SearchInput

PropTypeDefaultDescription
value / defaultValue / onValueChangestringControlled or uncontrolled text.
onSearch(value) => voidEnter, or picking a recent search.
shortcut"/" | "mod+k"Focuses the field from anywhere. Shows a key hint while empty.
recent / onClearRecentstring[] / () => voidRecent searches shown while focused and empty.
loadingbooleanfalseShows a spinner in place of the search icon.
size"sm" | "default" | "lg""default"Height. Matches Input sizes.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add search-input# or, with the registry in components.jsonnpx shadcn@latest add @prodular/search-input