Combobox
Searchable autocomplete dropdown control combining text input typing with filtered Radix Popover item selection.
// Plain markup
import { Combobox } from "@shavin/ui";Search or type a new value
Typing filters the list. Whatever is typed is the value, so people can enter a merchant that is not listed yet.
Component Source
import { useState } from "react";
import { Combobox } from "@shavin/ui";
const MERCHANTS = ["Costco", "Trader Joe's", "Whole Foods", "Target", "Shell", "Netflix", "Spotify", "City Water & Power"];
export function MerchantField() {
const [merchant, setMerchant] = useState("");
return (
<div className="flex w-64 flex-col gap-1.5">
<label htmlFor="merchant" className="text-sm font-medium text-fg">Merchant</label>
<Combobox
id="merchant"
value={merchant}
onChange={setMerchant}
options={MERCHANTS}
placeholder="Search or add a merchant"
/>
</div>
);
}Small, without hover preview
size is sm or md (default). hoverPreview (default true) shows the hovered option in the field; set it to false so the value only changes on click or Enter.
Component Source
const CURRENCIES = ["USD", "EUR", "GBP", "CAD", "AUD", "JPY", "INR"];
const [currency, setCurrency] = useState("USD");
<Combobox
aria-label="Currency"
size="sm"
hoverPreview={false}
value={currency}
onChange={setCurrency}
options={CURRENCIES}
/>Select, Dropdown or Combobox
| Select | Dropdown | Combobox | |
|---|---|---|---|
| Best for | Picking one value from a styled list, with groups or leading icons | Compact pickers and filters; the native variant for the OS picker on phones | Long lists people search by typing, or values that may not be in the list |
| Popup | Custom listbox (Radix Select) | Custom listbox by default; variant="native" renders a real <select> | Text input with a filtered list |
| Free text | No | No | Yes, any typed string is the value |
| Options | { value, label, prefix? } or groups | { value, label } | Strings |
| Sizes | sm, md, lg | sm, md | sm, md |
| Empty state | Shows placeholder until something is picked | Starts on the first option | Shows placeholder while empty |
All three support arrow keys, Enter and Escape. Select and the default Dropdown also jump to an option as you type its first letters.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string | — | Selected or typed string value. |
| onChange* | (value: string) => void | — | Callback fired when user selects or types a value string. |
| options* | string[] | — | List of string option items for autocomplete filtering. |
| prettyOptionLabel | (val: string) => string | — | Optional formatter function for option labels. |
| size | "sm" | "md" | md | Size variant: "sm" (32px height) or "md" (40px height), matching Select sm and md. Default "md". |
| hoverPreview | boolean | true; | Preview the hovered option in the field as you move over the list. Default true; set false for a plain select that only applies on click. |
* required