Search inputNew
The field at the top of every list: ⌘K focuses it from anywhere, search runs after a pause, the magnifier blurs into a spinner while it loads.
Used forList and table headersDocs and help centresApp top barsPickers and sidebars
Install with the shadcn CLI
Older shadcn CLI, or a network that blocks ui.shadcn.com? Install by URL: shadcn add https://hairlineui.com/r/search-input.json. More
Templates
Need the whole page?
65 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
List and table headers
Search above customers, invoices or files.
Docs and help centres
A "/" shortcut like GitHub and MDN.
App top bars
A ⌘K field that focuses from anywhere.
Pickers and sidebars
Filter a long list as you type.
What it handles for you
Each search box ends up with its own timer, its own keyboard listener and a spinner bolted on beside it. This one has them built in and keeps them out of each other's way.
Debounced search
Runs after 250ms without typing; Enter runs it immediately.
A real shortcut
⌘K / Ctrl K or "/" focuses and selects the field, never while you type elsewhere.
Loading in place
The magnifier blurs into a spinner and back.
Clear and Escape
The clear button folds in with the first letter; Escape leaves the field.
Overview
Search fields usually wire their own debounce, shortcut and spinner, and the shortcut hint overlaps the text. This one runs onSearch after a pause (Enter runs it at once), focuses on ⌘K or "/" from anywhere on the page, steps its key hint aside as you type, and turns the magnifier into a spinner while results load.
States
- rest
- Magnifier, placeholder and the ⌘K hint.
- typing
- The hint folds away (320ms) and the clear button folds in.
- loading
- The magnifier blurs into a spinner (scale 0.6, 3px).
- focused by shortcut
- The field takes focus and selects its text.
Usage
Props
- onSearch
- (query: string) => void
- After `debounce` ms without typing, and at once on Enter.
- debounce= 250
- number
- Wait in ms.
- loading= false
- boolean
- Spinner in place of the magnifier.
- shortcut= "mod+k"
- "mod+k" | "/" | null
- Key that focuses the field.
- ...Input props
- InputProps
- label, size, value, onValueChange and every native prop.
Accessibility and motion
- Shares field.tsx with every text control: one surface, one focus ring, one way of showing hints and errors.
- role="searchbox"; the shortcut hint is aria-hidden (the key is a convenience, not a name).
- The browser's own cancel button is hidden in favour of the folding one.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/search-input.json


