Components
Search Input
A search field with a clear button and a shortcut hint.
/
<SearchInput />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/search-input.jsonimport { SearchInput } from "@/components/search-input"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A search field with an icon, a clear button and a shortcut key shown at the end. Pressing the key anywhere on the page focuses the field, unless you're typing somewhere else. Escape clears it.
import { SearchInput } from "@/components/search-input";
export function DocsSearch({ onSearch }: { onSearch: (q: string) => void }) {
return <SearchInput placeholder="Search docs" onChange={(e) => onSearch(e.target.value)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | "Search" | Accessible name. |
shortcut | string | "/" | Key that focuses the field. Empty for none. |
className | string | Classes for the wrapper. | |
...props | input props | Every native <input> prop: name, required, onChange and so on. |
It has no animation, so reduced motion changes nothing.