humanonlyweb/ui

Select

A single or multiple choice from a dropdown.

Markdown

Examples

Basic

  • LagosUTC+1
  • LondonUTC+0
  • New YorkUTC−5
  • TokyoUTC+9
  • SydneyUTC+10
Copy code

Multiple

  • Bug
  • Feature
  • Docs
  • Question
Copy code

API

PropTypeDefault
options

Options to choose from.

SelectOption<T>[][]
error

true marks the control invalid; a string also shows it as the message, replacing the hint.

string | boolean—
placeholder

Shown when nothing is selected.

string"Select an option"
multiple

Allow several selections; v-model becomes an array and the list stays open while picking.

booleanfalse
optional

Appends the optional translation to the label.

booleanfalse
disabled

Disables the control.

booleanfalse
label

Visible label, linked to the control.

string—
hint

Help text under the control, announced as its description.

string—
name

Form field name: submits the value with a native form, via hidden inputs.

string—
id

Id for the control; generated with useId() when omitted.

string—
modelValue

The selected value, or values with multiple.

T | T[]—
EventPayload
update:modelValue

v-model:modelValue update.

[value: T | T[] | undefined]
SlotProps
value

Trigger content, replacing the selected label or placeholder.

{ selected: SelectOption<T>[]; placeholder: string; }
option

Option content.

{ option: SelectOption<T>; selected: boolean; active: boolean; }
chevron

Replaces the trigger's chevron.

—
check

Replaces the selected option's check mark.

—

Types

export interface SelectOption<T extends SelectValue = SelectValue> {
  label: string;
  value: T;
  disabled?: boolean;
}

export type SelectValue = string | number;
Copy code

Styling

Parts
fieldfield-labelfield-optionalselect-controlselect-triggerselect-valueselect-chevronselect-listboxselect-optionselect-option-checkselect-option-labelfield-message
States
data-field-errordata-field-namedata-select-opendata-select-errordata-select-placeholderdata-select-activedata-field-tone

Keyboard

KeysAction
↓ / ↑Open, then move between options
Enter / SpaceOpen, or select the active option
Home / EndFirst / last option
Any letterJump to an option by label; repeat a letter to cycle
TabKeep the active option and close
EscapeClose

Accessibility

  • Focus stays on the trigger; the active option is set with aria-activedescendant.