Search Bar
Where next? Type a place — suggestions come grouped.
Preview
Usage
tsx
import { SearchBar } from "zostel-ui";
<SearchBar
placeholder="Where next?"
suggestions={[
{ value: "manali", label: "Manali", category: "Himachal Pradesh" },
{ value: "pokhara", label: "Pokhara", category: "Nepal" },
]}
onSearch={(query) => {}}
onSelect={(s) => go(s.value)}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | "Search destinations..." | The hint. |
suggestions | { value; label; category? }[] | [] | Grouped by category. |
onSearch | (query: string) => void | — | On every keystroke. |
onSelect | (suggestion) => void | — | When one is picked (Enter picks the highlighted one). With none highlighted, Enter submits the form the search sits in. |
className | string | — | More classes, merged with the component’s own (tailwind-merge). |
placeholderType:
stringDefault:
"Search destinations..."The hint.
suggestionsType:
{ value; label; category? }[]Default:
[]Grouped by category.
onSearchType:
(query: string) => voidDefault: —
On every keystroke.
onSelectType:
(suggestion) => voidDefault: —
When one is picked (Enter picks the highlighted one). With none highlighted, Enter submits the form the search sits in.
classNameType:
stringDefault: —
More classes, merged with the component’s own (tailwind-merge).