Components

Combobox

An input with a list of options where the user picks one or more items from a fixed list.

Source code

Click to see the source code for this component on GitHub. Feel free to copy it and adjust it for your own use.

Installation

To use the combobox inside a Vee-Validate form, see VeeCombobox.

Hand-rolled comboboxes
Older versions of this page built the combobox by hand from UiPopover and UiCommand. That still works (see the Command docs), but UiCombobox is now built on Reka UI's Combobox primitive and handles filtering, keyboard navigation, multiple selection and form values for you.

Combobox vs. Autocomplete

ComboboxAutocomplete
v-modelThe selected item(s): a string, number, object or an array when multipleThe text in the input (string)
Free-form textNo, the value must be one of the itemsYes, any text is a valid value
Selecting an itemSets the model to the item's valueFills the input with the item's text
On blurResets the input to the selectionKeeps the typed text
multiple / object valuesSupportedNot supported

Use a combobox when the user has to choose from a fixed list, or when you need objects or multiple selection. Use UiAutocomplete when suggestions are only a convenience.

Usage

Basic

The model holds the selected item. The input searches the list and shows the selection once the list closes.

Selected: (none)

Objects

Items can have any value, including objects. Use by to tell the combobox how to compare objects, and display-value on UiComboboxInput to control what the input shows for the selected object. Set text-value on the item so it can be searched.

Selected: nuxt.js

Groups

Use UiComboboxGroup and UiComboboxLabel to organise the items. Visible groups are divided by a line automatically, and groups that do not match the search are hidden along with their divider. Individual items can be disabled.

Multiple

Set multiple to allow more than one item. The model becomes an array. Reka UI recommends rendering the selection as tags: wrap a UiTagsInput in UiComboboxAnchor (with as-child) and render the input with UiTagsInputInput.

TypeScript
Rust

Selected: 2

Clearable

Use UiComboboxCancel to render a button that clears the search. Add reset-model-value-on-clear to also reset the model to null (or [] when multiple).

Custom item content

Items accept any content, such as icons, avatars or descriptions. Content that is not plain text needs text-value so the item can still be searched. Here the selected item also drives an icon placed before the input.

Open on focus or click

By default the list opens once the user starts typing or presses the arrow keys. Use open-on-focus or open-on-click to open it as soon as the input is focused or clicked.

Async

Fetch items from your API as the user types. Use ignore-filter so the results returned from the server are not filtered a second time on the client, and listen to update:modelValue on UiComboboxInput to get the search term. The selected object is kept in the model, so its label survives while the list of results changes.

Selected: (none)

Form

Pass a name to include the selected value when the surrounding <form> is submitted. For validation, see VeeCombobox.

Disabled

Set disabled on the root to prevent interaction, or on individual items.

Props

Combobox

PropTypeDefaultDescription
v-modelT | T[]The selected item. An array when multiple.
default-valueT | T[]Initial selection when uncontrolled.
multiplebooleanfalseAllow selecting more than one item.
bystring | ((a: T, b: T) => boolean)Property name or comparator used to compare object values.
v-model:openbooleanControls whether the list is open.
default-openbooleanInitial open state when uncontrolled.
open-on-focusbooleanfalseOpen the list when the input is focused.
open-on-clickbooleanfalseOpen the list when the input is clicked.
ignore-filterbooleanfalseDisable the built-in filtering. Use it when you filter the items yourself, for example with data from an API.
reset-search-term-on-blurbooleantrueReset the search term when the input loses focus.
reset-search-term-on-selectbooleantrueReset the search term when an item is selected.
reset-model-value-on-clearbooleanfalseReset the model when UiComboboxCancel is used.
highlight-on-hoverbooleantrueHighlight items on hover.
namestringName used when the combobox is part of a native form.
requiredbooleanMarks the field as required.
disabledbooleanPrevents interaction.
dir"ltr" | "rtl"Reading direction.

The root emits update:modelValue, update:open and highlight.

ComboboxInput

PropTypeDescription
display-value(value: T) => stringWhat the input shows for the selected item once the list is closed. Needed for object values. Not used with multiple.

Emits update:modelValue with the text in the input as the user types.

ComboboxContent

Accepts all of the Reka UI popper content props. The ones used most often are:

PropTypeDefaultDescription
hide-when-emptybooleanfalseHide the popup while no item matches.
side"top" | "right" | "bottom" | "left""bottom"Preferred side of the input.
side-offsetnumber8Distance in pixels from the input.
position"inline" | "popper""popper"Positioning strategy.

ComboboxItem

PropTypeDescription
valueTThe value stored in the model when the item is selected.
text-valuestringPlain text used to search the item. Needed when the content is not plain text.
disabledbooleanPrevents the item from being selected.
iconstringIcon shown when the item is selected. Defaults to lucide:check.

Accessibility

The input has the combobox role and the items are exposed as a listbox. Focus stays in the input while you move through the items.

KeyDescription
ArrowDown / ArrowUpOpens the list, then moves the highlight.
EnterSelects the highlighted item.
EscCloses the list and keeps focus in the input.
TabMoves focus away. The input resets to the current selection.