Expand Search

A search icon that grows into a field. Opens with the / key.

no dependenciesMIT · free

Click the icon or press /

Installation

npx shadcn@latest add https://ombakui.com/r/expand-search.json

Usage

import { ExpandSearch } from "@/components/expand-search";

<ExpandSearch onSearch={setQuery} onSubmit={runSearch} />

Props

PropTypeDefaultDescription
onSearch(query: string) => void–Called on every keystroke.
onSubmit(query: string) => void–Called when Enter is pressed.
placeholderstring"Search…"Placeholder once open.
widthstring"18rem"Width when open, any CSS length.
hotkeybooleantrueOpen with "/" from anywhere on the page.
classNamestring–