Select
A field with a dropdown list of values.
- Awaiting payment
- Paid
- Shipped
- Delivered
- Canceled
The customer gets an email about the new status
<template> <NuiSelect v-model="status" :options="statuses" label="Order status" description="The customer gets an email about the new status" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiSelect } from '@numior/kit';import { ORDER_STATUSES } from './orders';const status = ref<string | null>('paid');const statuses = Object.entries(ORDER_STATUSES).map(([value, label]) => ({ value, label }));</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];Pass the options to options as { value, label } entries.
Installation
import { NuiSelect } from '@numior/kit';Usage
Change the size, the side the list opens on and the states of the field.
- Anna Turner
- Ian Bell
- Maria Kim
- Owen Smith
- Dina Ahmed
<template> <NuiSelect placeholder="Pick a manager" label="Manager" v-model="manager" :options="managers" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiSelect } from '@numior/kit';import { team } from './team';const manager = ref<string | null>(null);const managers = team.map((person) => ({ value: person.id, label: person.name }));</script>export interface Employee { readonly id: string; readonly name: string; readonly role: string; readonly email: string;}export const team: readonly [Employee, Employee, Employee, Employee, Employee] = [ { id: 'anna', name: 'Anna Turner', role: 'Order manager', email: 'anna@example.com' }, { id: 'igor', name: 'Ian Bell', role: 'Warehouse', email: 'igor@example.com' }, { id: 'maria', name: 'Maria Kim', role: 'Support', email: 'maria@example.com' }, { id: 'oleg', name: 'Owen Smith', role: 'Purchasing', email: 'oleg@example.com' }, { id: 'dina', name: 'Dina Ahmed', role: 'Marketing', email: 'dina@example.com' },];To let users search the list, use a Combobox.
Examples
Split the options into groups
Pass a { label, items } entry.
- Northeast
- Boston
- Midwest
- Chicago
- Northwest
- Seattle
- Portland
- South
- Austin
- Mountain states
- DenverDelivery is paused until Monday
<template> <NuiSelect v-model="city" :options="cities" label="Delivery city" placeholder="Pick a city" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiSelect, type NuiOptionSource } from '@numior/kit';const city = ref<string | null>(null);const cities: NuiOptionSource<string> = [ { label: 'Northeast', items: [{ value: 'bos', label: 'Boston' }] }, { label: 'Midwest', items: [{ value: 'chi', label: 'Chicago' }] }, { label: 'Northwest', items: [ { value: 'sea', label: 'Seattle' }, { value: 'pdx', label: 'Portland' }, ], }, { label: 'South', items: [{ value: 'aus', label: 'Austin' }] }, { label: 'Mountain states', items: [ { value: 'den', label: 'Denver', description: 'Delivery is paused until Monday', disabled: true, }, ], },];</script>An option with disabled stays in the list, but it cannot be picked and the arrow keys skip it.
Pick several values
Add multiple.
- Anna TurnerOrder manager
- Ian BellWarehouse
- Maria KimSupport
- Owen SmithPurchasing
- Dina AhmedMarketing
<template> <NuiSelect v-model:values="recipients" :options="people" label="Notify about new orders" placeholder="Pick team members" multiple clearable /></template><script setup lang="ts">import { ref } from 'vue';import { NuiSelect } from '@numior/kit';import { team } from './team';const recipients = ref(['anna', 'maria']);const people = team.map((person) => ({ value: person.id, label: person.name, description: person.role,}));</script>export interface Employee { readonly id: string; readonly name: string; readonly role: string; readonly email: string;}export const team: readonly [Employee, Employee, Employee, Employee, Employee] = [ { id: 'anna', name: 'Anna Turner', role: 'Order manager', email: 'anna@example.com' }, { id: 'igor', name: 'Ian Bell', role: 'Warehouse', email: 'igor@example.com' }, { id: 'maria', name: 'Maria Kim', role: 'Support', email: 'maria@example.com' }, { id: 'oleg', name: 'Owen Smith', role: 'Purchasing', email: 'oleg@example.com' }, { id: 'dina', name: 'Dina Ahmed', role: 'Marketing', email: 'dina@example.com' },];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.
- Peter WolfeBoston
- Lena OrtizChicago
- Tim SayedDenver
- Vera LaneBoston
- Glen NashAustin
- Evan PorterSeattle
- Mary CooperPortland
- Paul HawkinsBoston
- Olga GrahamChicago
- Sam EllisDenver
- Nina HartAustin
- Alina YusufPortland
The receipt goes to the customer’s email
<template> <div class="flex flex-col gap-3"> <NuiSelect v-model="customer" :options="buyers" :get-key="keyOf" label="Customer" placeholder="Pick a customer" /> <p class="m-0 text-sm text-muted-foreground">{{ receipt }}</p> </div></template><script setup lang="ts">import { computed, ref } from 'vue';import { NuiSelect } from '@numior/kit';import { customers, type Customer } from './customers';const customer = ref<Customer | null>(null);const buyers = customers.map((person) => ({ value: person, label: person.name, description: person.city,}));const receipt = computed(() => customer.value === null ? 'The receipt goes to the customer’s email' : `The receipt goes to ${customer.value.email}`,);const keyOf = (person: Customer): string => String(person.id);</script>export interface Customer { readonly id: number; readonly name: string; readonly city: string; readonly email: string; readonly phone: string; readonly orders: number; readonly spent: number;}export const customers: readonly Customer[] = [ { id: 1, name: 'Peter Wolfe', city: 'Boston', email: 'peter.wolfe@example.com', phone: '(617) 555-0101', orders: 14, spent: 2480, }, { id: 2, name: 'Lena Ortiz', city: 'Chicago', email: 'lena.ortiz@example.com', phone: '(312) 555-0102', orders: 3, spent: 295, }, { id: 3, name: 'Tim Sayed', city: 'Denver', email: 'tim.sayed@example.com', phone: '(303) 555-0103', orders: 8, spent: 1920, }, { id: 4, name: 'Vera Lane', city: 'Boston', email: 'vera.lane@example.com', phone: '(617) 555-0104', orders: 1, spent: 180, }, { id: 5, name: 'Glen Nash', city: 'Austin', email: 'glen.nash@example.com', phone: '(512) 555-0105', orders: 5, spent: 645, }, { id: 6, name: 'Evan Porter', city: 'Seattle', email: 'evan.porter@example.com', phone: '(206) 555-0106', orders: 2, spent: 440, }, { id: 7, name: 'Mary Cooper', city: 'Portland', email: 'mary.cooper@example.com', phone: '(503) 555-0107', orders: 11, spent: 1300, }, { id: 8, name: 'Paul Hawkins', city: 'Boston', email: 'paul.hawkins@example.com', phone: '(617) 555-0108', orders: 6, spent: 965, }, { id: 9, name: 'Olga Graham', city: 'Chicago', email: 'olga.graham@example.com', phone: '(312) 555-0109', orders: 4, spent: 530, }, { id: 10, name: 'Sam Ellis', city: 'Denver', email: 'sam.ellis@example.com', phone: '(303) 555-0110', orders: 9, spent: 2190, }, { id: 11, name: 'Nina Hart', city: 'Austin', email: 'nina.hart@example.com', phone: '(512) 555-0111', orders: 2, spent: 755, }, { id: 12, name: 'Alina Yusuf', city: 'Portland', email: 'alina.yusuf@example.com', phone: '(503) 555-0112', orders: 7, spent: 820, },];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.
- Furniture
- Lighting
- Textiles
<template> <NuiSelect v-model="category" :options="categories" label="Product category" placeholder="Pick a category" clearable /></template><script setup lang="ts">import { ref } from 'vue';import { NuiSelect } from '@numior/kit';import { categories } from './products';const category = ref<string | null>('lamps');</script>export interface Product { readonly sku: string; readonly name: string; readonly category: string; readonly price: number; readonly stock: number;}export interface Category { readonly value: string; readonly label: string; readonly children?: readonly Category[];}export const categories: readonly Category[] = [ { value: 'furniture', label: 'Furniture', children: [ { value: 'seating', label: 'Chairs' }, { value: 'tables', label: 'Tables' }, { value: 'storage', label: 'Storage' }, ], }, { value: 'lighting', label: 'Lighting', children: [ { value: 'lamps', label: 'Lamps' }, { value: 'pendants', label: 'Pendants' }, ], }, { value: 'textile', label: 'Textiles', children: [ { value: 'throws', label: 'Throws' }, { value: 'pillows', label: 'Pillows' }, ], },];export const products: readonly Product[] = [ { sku: 'S-101', name: 'Oslo armchair', category: 'seating', price: 249, stock: 12 }, { sku: 'S-104', name: 'Bergen chair', category: 'seating', price: 89, stock: 34 }, { sku: 'S-110', name: 'Loft stool', category: 'seating', price: 45, stock: 0 }, { sku: 'T-201', name: 'Malmo desk', category: 'tables', price: 329, stock: 7 }, { sku: 'T-207', name: 'Tromso coffee table', category: 'tables', price: 139, stock: 15 }, { sku: 'H-301', name: 'Vik shelving unit', category: 'storage', price: 199, stock: 9 }, { sku: 'H-305', name: 'Fjord dresser', category: 'storage', price: 299, stock: 4 }, { sku: 'L-401', name: 'Nord table lamp', category: 'lamps', price: 69, stock: 41 }, { sku: 'L-408', name: 'Arc floor lamp', category: 'lamps', price: 119, stock: 18 }, { sku: 'L-412', name: 'Sphere pendant', category: 'pendants', price: 99, stock: 22 }, { sku: 'X-501', name: 'Wool throw', category: 'throws', price: 59, stock: 56 }, { sku: 'X-507', name: 'Linen pillow', category: 'pillows', price: 29, stock: 80 },];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 | |
|---|---|---|---|---|
options*required required | 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 |