Combo Box
ComboBox combines a text input with a filtered option list.
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
<ComboBox
options={[
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
]}
placeholder="Select a city"
defaultValue="lisbon"
/>Installation
pnpm dlx wideset add combo-box
Copies the component and any Wideset components it uses into your project.
Examples
Variants
Primary is the default. Danger marks a value that failed validation, such as free text that matches no city when one is required; put the reason in the FormField's errorText, which FormField links to the control, because the red border alone does not reach screen reader users.
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
const CITIES = [
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
];
export default function ComboBoxVariants() {
return (
<div className="gap-ws-12 flex flex-col">
{(['primary', 'danger'] as const).map((variant) => (
<ComboBox key={variant} variant={variant} options={CITIES} placeholder="Select a city" />
))}
</div>
);
}Presets
Border is the default, for a combo box in a form or on the page. Ghost drops the frame and shows a soft background on hover, for a combo box inside a surface that already has one, such as a toolbar or an inline editor.
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
const CITIES = [
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
];
export default function ComboBoxPresets() {
return (
<div className="gap-ws-12 flex flex-col">
{(['border', 'ghost'] as const).map((preset) => (
<ComboBox key={preset} preset={preset} options={CITIES} defaultValue="lisbon" />
))}
</div>
);
}Sizes
Medium is the default for forms. Small fits filter bars and dense tables, large a short form that is the main task on the page. Match the size of the fields and buttons next to it.
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
const CITIES = [
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
];
export default function ComboBoxSizes() {
return (
<div className="gap-ws-12 flex flex-col">
{(['sm', 'md', 'lg'] as const).map((size) => (
<ComboBox key={size} size={size} options={CITIES} placeholder="Select a city" />
))}
</div>
);
}Icons
An option can carry a prefix (an icon, an avatar, a short text). The prefix of the chosen option is repeated in the closed field, so give every option one or none: a list where only some have a glyph reads as two kinds of item.
import { RiBuilding2Line, RiHome4Line, RiMapPinLine } from '@remixicon/react';
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
const places = [
{ value: 'office', label: 'Office', prefix: <RiBuilding2Line className="size-ws-9" /> },
{ value: 'home', label: 'Home', prefix: <RiHome4Line className="size-ws-9" /> },
{ value: 'client', label: 'Client site', prefix: <RiMapPinLine className="size-ws-9" /> },
];
export default function ComboBoxIcons() {
return (
<div className="gap-ws-5 flex flex-wrap items-center justify-center">
<ComboBox options={places} defaultValue="office" />
<ComboBox options={places} placeholder="Where do you work?" />
</div>
);
}States
Typing filters the list and highlights the matching part of each option. By default the typed text can become the value even when no option matches; with disallowCustomValue it only filters the list. A disabled combo box cannot be opened, typed into or cleared, and is skipped by the keyboard.
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
const CITIES = [
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
];
export default function ComboBoxStates() {
return (
<div className="gap-ws-12 flex flex-col">
<ComboBox options={CITIES} placeholder="Select a city" />
<ComboBox options={CITIES} defaultValue="lisbon" />
<ComboBox options={CITIES} placeholder="Select a city" disabled />
</div>
);
}API reference
ComboBox
| Name | Description | Default |
|---|---|---|
children | Sub-components for composable usage (`ComboBox.Trigger`, `ComboBox.Content`, `ComboBox.Item`). Use instead of the default rendering when you need custom layouts or full rendering control. ReactNode | — |
className | Additional CSS classes applied to the trigger element. Width utilities (e.g. `w-[20rem]`) override the default width. string | — |
clearable | Whether to show a clear button in the trigger when a value is selected or text is typed. boolean | — |
clearSelectionAriaLabel | Accessible label for the clear-selection button rendered in the trigger. Defaults to `'Clear selection'`. string | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
defaultValue | Initial value for uncontrolled usage. Seeds the selection on first render only; ignored afterwards. string | — |
disabled | Disables the combobox: it cannot be opened, typed into, or cleared, and is removed from the tab order. boolean | — |
disallowCustomValue | Restricts the value to existing options. When enabled, typed text only filters the list instead of becoming a custom value; clearing the input deselects. boolean | — |
onChange | Called when the selected option or typed custom value changes. Receives the next string value and fires in both controlled and uncontrolled modes. ((value: string) => void) | — |
onClear | Called when the clear button is clicked. Use for custom reset logic beyond clearing the value. (() => void) | — |
options | Array of options to display in the dropdown. Each item requires `value` and `label`. SelectOptionType<Record<string, unknown>>[] | — |
placeholder | Placeholder text shown in the trigger when no option is selected and no custom value is typed. string | — |
preset | Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. 'border''ghost' | — |
size | Controls the height, padding, and typography size of the trigger and its filter input. 'sm''md''lg' | — |
value | Controlled selected value. Matches an option `value`, or any custom string when custom values are allowed. string | — |
variant | Color variant. `danger` applies error styling for form validation feedback. 'primary''danger' | 'primary' |
ComboBox.Content
| Name | Description | Default |
|---|---|---|
children | Composed content, or a render function called for each filtered option. ReactNode | ((option: ComboBoxOption) => ReactNode) | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
ComboBox.HighlightedLabel
| Name | Description | Default |
|---|---|---|
label* | Option label whose matching text is highlighted. string | — |
search* | Search text to highlight within the label. string | — |
ComboBox.Icon
| Name | Description | Default |
|---|---|---|
icon* | The icon to render inside a `TextInput.Prefix` / `TextInput.Suffix`. Sized automatically from the input's `size`. RemixiconComponentType | — |
className | Layout/context overrides for the icon. string | — |
ComboBox.Item
| Name | Description | Default |
|---|---|---|
value* | Option value this item represents. Must match the `value` of an option passed to the parent `ComboBox` to inherit its label, prefix, and disabled state. string | (readonly string[] & string) | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | Disables the item: it cannot be selected and is skipped during keyboard navigation. Defaults to the matching option's `disabled` flag. boolean | — |
isHighlighted | Overrides the keyboard-highlight state. By default derived from the parent `ComboBox` arrow-key navigation. boolean | — |
isSelected | Overrides the selected state. By default derived from the parent `ComboBox` value. boolean | — |
variant | Visual variant of the row. `danger` renders the item in error colors (e.g. destructive actions). Defaults to the matching option's `variant`. 'primary''danger' | — |
ComboBox.Prefix
| Name | Description | Default |
|---|---|---|
content | Figma sets the affix inset from the *kind* of content, not just the size: `Type=Text` is roomier than an icon, and an icon button — which carries its own internal padding — is tighter still. Figma's `Avatar`, `Entity` and `Icon` types all resolve to the same numbers, so they share `icon` here. What this affix holds. Figma insets an affix by the kind of content it carries, not only by `size` — text sits roomier than an icon, and an icon button (which has padding of its own) tighter than both. Inferred from `children` when omitted, so the common cases need no prop. 'text''icon''iconButton' | — |
inner | boolean | — |
size | 'sm''md''lg' | — |
ComboBox.Trigger
| Name | Description | Default |
|---|---|---|
clearSelectionAriaLabel | Accessible label for the clear-selection button. Defaults to `'Clear selection'`. string | 'Clear selection' |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | Disables the trigger: it cannot be opened, typed into, or cleared, and is removed from the tab order. boolean | — |
displayedLabel | Overrides the label shown in the closed trigger. By default the selected option's label (or the custom value). string | — |
hasClearButton | Overrides whether the clear button is shown. By default derived from the parent `ComboBox` `clearable` prop and current value. boolean | — |
hasPrefix | Whether the trigger renders a `ComboBox.Prefix` — removes the left padding so the prefix sits flush. Detected automatically in the simple (non-composed) mode. boolean | — |
inputRef | Ref to the filter input rendered while open. By default provided by the parent `ComboBox`. RefObject<HTMLInputElement | null> | — |
inputValue | Overrides the filter input value. By default derived from the parent `ComboBox` search/selection state. string | — |
onInputBlur | Blur handler for the filter input. Fires in addition to the built-in close-on-blur behavior. FocusEventHandler<HTMLInputElement> | — |
onInputChange | Called with the new text whenever the filter input changes. Fires in addition to the parent `ComboBox` filtering. ((value: string) => void) | — |
onInputKeyDown | Keydown handler for the filter input. Fires in addition to the built-in keyboard navigation. KeyboardEventHandler<HTMLInputElement> | — |
open | Overrides the open state. By default derived from the parent `ComboBox`. boolean | — |
placeholder | Placeholder text shown when no option is selected. string | — |
preset | Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. 'border''ghost' | — |
size | Controls the height, padding, and typography size of the trigger. 'sm''md''lg' | — |
variant | Color variant. `danger` applies error styling for form validation feedback. 'primary''danger' | — |
<input> is passed through to it. See MDN: <input>.Accessibility
- A
<label htmlFor>does not reach the combobox. Name it witharia-label, or giveFormFieldanid(it lands on the label) and pass that id asaria-labelledby. - Arrow keys move the highlight, Enter picks, Escape closes and drops the typed filter.
- The clear button is labelled “Clear selection”; translate with
clearSelectionAriaLabel.
| Part | Renders | Description |
|---|---|---|
| ComboBoxRenders no element | — | A searchable selection control that can accept custom values. Name it with `aria-label` or `aria-labelledby`; a `<label htmlFor>` does not reach it. |
| ComboBox.ContentRenders no element | — | The content surface rendered within `ComboBox`. |
| ComboBox.HighlightedLabelOnly while typing | — | An option label with matching search text highlighted. |
| ComboBox.IconRenders no element | — | `ComboBox.Icon` is `TextInput.Icon`; same props. |
| ComboBox.ItemRenders no element | — | An individual item within `ComboBox`. |
| ComboBox.PrefixRenders no element | — | `ComboBox.Prefix` is `TextInput.Prefix`; same props. |
| ComboBox.TriggerRenders no element | <input> | The control that opens or toggles the associated content. |
import { ComboBox } from '@/components/ui/wideset/combo-box/ComboBox';
<ComboBox
options={[
{ value: 'lisbon', label: 'Lisbon' },
{ value: 'berlin', label: 'Berlin' },
{ value: 'warsaw', label: 'Warsaw' },
{ value: 'amsterdam', label: 'Amsterdam' },
]}
placeholder="Select a city"
defaultValue="lisbon"
/>