Browse components
Expand Search
A round search button that stretches into a field on press, focuses itself, pops in a clear button as you type, and folds back on Escape or when it loses focus empty.
Installation
npx shadcn@latest add @glint-ui/expand-searchFirst time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/expand-search.json
Usage
import { ExpandSearch } from "@/components/ui/expand-search";
<ExpandSearch onSearch={(q) => router.push(`/search?q=${q}`)} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| width | number | 260 | Width in px when open. |
| placeholder | string | "Search…" | Placeholder text. |
| align | "right" | "left" | "right" | Which side stays put while it grows. |
| onSearch | ReactNode | — | (query) => void, called on Enter. |
| onChange | ReactNode | — | (query) => void, called on every keystroke. |
| className | string | — | Extra classes for the root element. |