Skip to content

Combobox ​

A field with a list that narrows as you type.

Pass the options to options, as for a Select. The list keeps the options whose label contains the typed text, in any letter case.

Installation ​

ts
import { NuiCombobox } from '@numior/kit';

Usage ​

Change the size and the states of the field, then find a customer by name.

Text shown in the empty field.

Where the list opens, such as bottom-start or top.

size
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.

Label of the control. Inside NuiField the field provides the label.

Error text below the control. Puts the control into the error state.

The search ignores case, Latin accents and the difference between the Russian «е» and «ё». Your own function in filter gets the text in lower case only and compares on its own.

Examples ​

Pick several values ​

Add multiple.

NewOn sale

Type a tag and press Enter to add it

The picked values show as chips in the field. Pass customValue to turn typed text into a new value when the user presses Enter and no option is highlighted.

Search on the server ​

Turn off the filter and handle the search event.

Keep loading on while the request runs, and ignore answers that arrive for an older query.

Show more data in an option ​

Describe the row in the option slot.

Accessibility ​

The focus stays in the field while the arrow keys move through the options, and a screen reader reads the highlighted one. Tab skips the clear, list and chip remove buttons: Backspace in an empty field removes the last chip.

Keys
Action
↓
Opens the list and highlights the next option.
↑
Opens the list and highlights the previous option.
↵
Selects the highlighted option. With customValue, adds the typed text.
Esc
Closes the list. A dialog around the field stays open.
⇥
Closes the list and moves the focus on.
⌫
In an empty field with multiple, removes the last chip.

API ​

Props

Name
Type
Default
Description
optionsrequired
NuiOptionSource<T>
—
List options, optionally in groups.
multiple
boolean
false
Lets the user pick several values. They show as chips, and the list stays open after each pick.
clearable
boolean
false
Shows a button in the field that clears the selection.
placeholder
string
—
Text shown in the empty field.
name
string
—
The name attribute for form submission. Each value gets its own hidden input.
getKey
NuiOptionKey<T>
—
Function that returns the key of an object value. Without it the JSON of the value is the key.
filter
false | NuiComboboxFilter<T>
—
Custom function that matches options to the query. false turns matching off when the server searches.
loading
boolean
false
Shows a "Loading" row in the list.
loop
boolean
true
Arrow keys wrap from the last option to the first and back. On by default.
locale
string
—
Locale of the text search and the built-in texts, such as tr-TR. Defaults to the locale from createNuiConfig.
customValue
((text: string) => T)
—
Function that turns the typed text into a value. Enter adds it when no option is highlighted.
placement
Placement
"bottom-start"
Where the list opens, such as bottom-start or top.
emptyLabel
string
—
Text when nothing matches. Defaults to "No matches" from the dictionary.
loadingLabel
string
—
Text of the loading row. Defaults to "Loading" from the dictionary.
clearLabel
string
—
Clear button label for screen readers. Defaults to "Clear" from the dictionary.
removeLabel
string
—
Chip remove button label for screen readers. Defaults to "Remove" from the dictionary.
toggleLabel
string
—
List button label for screen readers. Defaults to "Show options" from the dictionary.
id
string
—
Id of the control. Defaults to the one from NuiField or is generated automatically.
size
NuiSize
"md"
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.
disabled
boolean
—
Disables the control. Inside NuiField it defaults to the field value.
readonly
boolean
—
Prevents changes to the value, which stays selectable and copyable. Inside NuiField it defaults to the field value.
required
boolean
—
Marks the control as required. Inside NuiField it defaults to the field value.
invalid
boolean
—
Shows the error state without a text. With error it turns on by itself.
label
string
—
Label of the control. Inside NuiField the field provides the label.
description
string
—
Hint below the control. Screen readers announce it with the control.
error
string
—
Error text below the control. Puts the control into the error state.
reserveError
boolean
false
Reserves space for the error so the form does not shift when it appears.

Models

Name
Type
Default
Description
v-model
T | null
null
Selected value, or null, when multiple is off.
v-model:values
T[]
[]
Array of selected values when multiple is on.

Events

Name
Payload
Description
search
[query: string]
Fires on every input with the query text.

Slots

Name
Slot props
Description
option
{ option: NuiOption<T>; selected: boolean; active: boolean; }
Custom option markup. Receives option, selected and active.

Texts

Key
Russian
English
clear
Очистить
Clear
empty
Ничего не найдено
No matches
remove
Убрать
Remove
toggle
Показать варианты
Show options

Edit this page

Search

Esc