Expanding search
An icon that morphs into a search field with results beneath it.
npx shadcn@latest add @silicon-ui/expanding-searchInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/expanding-searchManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/expanding-search/expanding-search.tsx
- components/silicon-ui/expanding-search/expanding-search.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
label*Names the button, the field, and the results, such as "Search projects and docs". | string | — |
items* | ExpandingSearchItem[] | — |
suggestionsShown before anything is typed, such as recent searches. | ExpandingSearchItem[] | [] |
suggestionsLabel | string | "Recent" |
placeholder | string | — |
onSelect | (item: ExpandingSearchItem) => void | — |
onExpandedChange | (expanded: boolean) => void | — |
expandedWidthThe widest the field grows. It never grows past its container. | number | 360 |
maxResults | number | 6 |
anchorThe edge the button sits on; the field grows away from it. | "start" | "end" | "end" |
emptyHintA short tip under the empty state. | string | "Try a shorter word or check the spelling." |
className | string | — |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens