Skip to content

Select

Use drop-down menus to display and select content from many options.

Basic Usage

Standard single select for a wide variety of scenarios.

Basic Usage

Disabled Option

Set the disabled property in an option to disable it.

Disabled Option

Disabled State

Use the disabled property to disable the entire select component.

Option 1
Disabled State

Clearable Single Select

Set the clearable property to allow clearing the selected value.

Option 1
Clearable

Multiple Select

Set the multiple property to enable multiple selection. In this case, v-model will be an array of selected values.

Multiple Select

Collapse Tags

When in multiple selection mode, use the collapse-tags property to collapse tags.

Option 1Option 2 +1
Collapse Tags

Filterable

Set the filterable property to enable the search feature.

Filterable

Set the remote and remote-method properties to search for data from a server.

Remote Search

Allow Create

Set the allow-create property to allow users to create new items. Must be used with filterable.

Allow Create

Virtual Scroll

When dealing with a large number of options, use virtual scrolling to optimize performance. Set the virtual-scroll property to enable it.

Virtual Scroll

Full Virtual Scroll Configuration

Customize row height and container height for virtual scrolling using item-height and height properties.

  • virtual-scroll: Enable virtual scrolling.
  • item-height: Height for each option (default 34px).
  • height: Height for the dropdown container (default 274px).
Full Virtual Scroll Configuration

Different Sizes

Use the size property to change the size of the select input.

Different Sizes

Use in Nuxt

The Select component fully supports Nuxt 3/4 SSR rendering. In Nuxt projects, the component is auto-imported.

Use in Nuxt

SSR Notes:

  • ✅ Basic selection functionality is fully supported.
  • ✅ Multiple selection and tag collapsing are supported.
  • ✅ Option grouping and searching are supported.
  • ✅ Remote search is supported.
  • ✅ Virtual scrolling (initializes in basic mode on the server, optimizes automatically upon client activation).
  • ⚠️ DOM methods like focus() and blur() must be called inside onMounted.

SSR Safety

The Select component has passed comprehensive SSR tests, ensuring that server-side and client-side rendered HTML structures are consistent, maintaining compatibility with Nuxt's hydration process.

API

Props

PropDescriptionTypeDefault
model-value / v-modelBinding valuestring | number | boolean | array
optionsOption dataSelectOption[][]
placeholderPlaceholder textstring
disabledWhether to disablebooleanfalse
clearableWhether it is clearablebooleanfalse
sizeInput size'large' | 'default' | 'small''default'
multipleWhether multiple selection is enabledbooleanfalse
multiple-limitMax number of labels in multiple selection, 0 for unlimitednumber0
filterableWhether search is enabledbooleanfalse
filter-methodCustom filter method(query: string) => void
remoteWhether to load options from a remote serverbooleanfalse
remote-methodRemote search method(query: string) => void
loadingWhether data is loadingbooleanfalse
loading-textLoading textstring'Loading...'
no-match-textText displayed when no data matches the searchstring'No matching data'
no-data-textText displayed when there is no datastring'No data'
allow-createWhether to allow creating new optionsbooleanfalse
collapse-tagsWhether to collapse tags in multiple selectionbooleanfalse
max-collapse-tagsMax number of visible tags before collapsingnumber1
virtual-scrollWhether to enable virtual scrollingbooleanfalse
item-heightHeight for each virtual scroll itemnumber34
heightHeight for the virtual scroll containernumber274
teleportedWhether to insert the dropdown into bodybooleantrue
fit-input-widthWhether the dropdown width matches the input widthbooleantrue
tag-typeType of tags'success' | 'info' | 'warning' | 'danger' | ''''
value-keyKey name for the valuestring'value'
label-keyKey name for the labelstring'label'

SelectOption

PropDescriptionTypeRequired
valueOption valuestring | number | booleanYes
labelOption labelstringYes
disabledWhether the option is disabledbooleanNo

Events

Event NameDescriptionCallback Parameters
changeTriggered when the selected value changes(value: any) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered when the clear button is clicked() => void
visible-changeTriggered when the dropdown visibility changes(visible: boolean) => void
remove-tagTriggered when a tag is removed in multiple selection(value: any) => void

Slots

Slot NameDescriptionScope
defaultCustom option content{ option: SelectOption }
prefixContent before the input
emptyContent when there is no data

Expose

NameDescriptionType
focusFocus the Select input() => void
blurBlur the Select input() => void

Theme Variables

The Select component uses the following CSS variables, which can be overridden for custom styling:

VariableDescriptionDefault
--yh-select-border-colorBorder colorvar(--yh-border-color)
--yh-select-hover-border-colorHover border colorvar(--yh-border-color-hover)
--yh-select-focus-border-colorFocus border colorvar(--yh-color-primary)
--yh-select-disabled-bg-colorDisabled background colorvar(--yh-fill-color-light)
--yh-select-tag-bg-colorTag background colorvar(--yh-fill-color)

Released under the MIT License.