Skip to content

Select ​

A field with a dropdown list of values.

The customer gets an email about the new status

Pass the options to options as { value, label } entries.

Installation ​

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

Usage ​

Change the size, the side the list opens on and the states of the field.

Text in the field while nothing is selected.

Side of the field the list opens on, bottom-start by default.

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

Label above the field. Inside NuiField the field provides the label.

Hint below the field. Screen readers announce it with the field.

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

To let users search the list, use a Combobox.

Examples ​

Split the options into groups ​

Pass a { label, items } entry.

An option with disabled stays in the list, but it cannot be picked and the arrow keys skip it.

Pick several values ​

Add multiple.

The values come to v-model:values, and when more than one is picked, the field shows how many.

Keep an object in the model ​

Pass getKey.

The receipt goes to the customer’s email

The field finds the picked option by the key from getKey, such as the customer id. Without it the key is the JSON of the object, and a copy with one changed field no longer matches its option.

Pick from a tree ​

Add children to the options.

The list opens with the branch of the picked value expanded. Mark a branch lazy to load it on expand, and fill its children in the load handler, as in a Tree.

Accessibility ​

The field has the combobox role and opens a listbox of options, or a tree for nested ones. As with a native <select>, typing the first letters on the closed field picks a matching option in a flat list of single values.

Keys
Action
↵
Opens the list at the selected option. In the list, picks the option and closes.
Space
Opens the list. With multiple, toggles the option.
↓
Opens the list at the first option. In the list, moves to the next one.
↑
Opens the list at the last option. In the list, moves to the previous one.
Home
Moves to the first option.
End
Moves to the last option.
Esc
Closes the list.
⇥
Closes the list and moves focus on.

API ​

Props

Name
Type
Default
Description
optionsrequired
NuiOptionSource<T> | readonly NuiTreeItem<T>[]
—
Options and groups of the list. Options with children or lazy turn the list into a tree.
multiple
boolean
false
Lets the user pick several values. The list stays open after each pick.
clearable
boolean
false
Shows a button that clears the value.
placeholder
string
—
Text in the field while nothing is selected.
name
string
—
Name the values are submitted with in a form, one field per value.
getKey
NuiOptionKey<T>
—
Function that returns a key for an object value. Without it, the JSON of the value is used.
loop
boolean
true
Arrow keys wrap from the last option to the first and back.
loading
boolean
false
Shows a "Loading" row in the list while the options load.
locale
string
—
Locale of the built-in texts of this field, such as en-US. Defaults to the locale from createNuiConfig.
placement
Placement
"bottom-start"
Side of the field the list opens on, bottom-start by default.
emptyLabel
string
—
Text of an empty list. Defaults to "No options" 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.
toggleLabel
string
—
Toggle button label for screen readers. Defaults to "Show options" from the dictionary.
countLabel
((count: number) => string)
—
Function for the field text when several values are picked. Defaults to "3 selected".
id
string
—
Id of the field. Defaults to the one from NuiField or is generated automatically.
size
NuiSize
"md"
Changes the size of the field: sm, md or lg. The theme density shifts the height of each size.
disabled
boolean
—
Disables the field. Inside NuiField it defaults to the field value.
readonly
boolean
—
Shows the value but does not open the list. Inside NuiField it defaults to the field value.
required
boolean
—
Marks the field as required with aria-required. Inside NuiField it defaults to the field value.
invalid
boolean
—
Shows the error state without a text. Inside NuiField it defaults to the field value.
label
string
—
Label above the field. Inside NuiField the field provides the label.
description
string
—
Hint below the field. Screen readers announce it with the field.
error
string
—
Error text below the field. Puts the field 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 without multiple.
v-model:values
T[]
[]
Selected values with multiple.

Events

Name
Payload
Description
load
[item: NuiTreeItem<T>]
Fires when an option with lazy is expanded. Load its children.

Slots

Name
Slot props
Description
value
{ selected: NuiOption<T>[]; }
Custom markup of the value in the field. Receives the selected options.
option
{ option: NuiTreeItem<T>; selected: boolean; active: boolean; }
Custom markup of an option in the list. Receives the option and its state.

Texts

Key
Russian
English
clear
Очистить
Clear
count
({ count }) => `Выбрано: ${count}`
({ count }) => `${count} selected`
empty
Нет вариантов
No options
toggle
Показать варианты
Show options

Edit this page

Search

Esc