Skip to content

Select (Native)

TuiSelectNative is a component encapsulated based on the browser's native HTML <select> element. Compared to the feature-rich TuiSelect, it is more lightweight, and its interactions strictly follow the native behavior of the operating system or browser. It is primarily used in scenarios where UI customization requirements are low or where native controls are specifically needed.

Basic Usage

Configuration-based Rendering

Pass an array of options through the options property. By default, it recognizes the label and value fields, but these can be customized using labelKey and valueKey.

html
<script setup>
import { ref } from 'vue';

const value = ref('');
const options = [
  { value: 'A', label: 'Option A' },
  { value: 'B', label: 'Option B' },
  { value: 'C', label: 'Option C', disabled: true }
];
</script>

<template>
  <TuiSelectNative 
    v-model="value" 
    :options="options" 
    placeholder="Please select" 
  />
</template>

Slot-based Rendering

Construct the component using the <TuiOptionNative> sub-component.

html
<template>
  <TuiSelectNative v-model="value">
    <TuiOptionNative label="Option A" value="A" />
    <TuiOptionNative label="Option B" value="B" />
  </TuiSelectNative>
</template>

Multiple Selection

Set the multiple attribute to enable multiple selection mode.

Note

The behavior of the native <select multiple> is typically an expanded List Box where users need to hold the Ctrl (Windows) or Command (Mac) key to perform multiple selections. This is completely different from the Tag-based display used by TuiSelect.

html
<template>
  <TuiSelectNative multiple v-model="selectedValues" :options="options" />
</template>

Decoration and Status

Clearable

Although the native Select does not support a clear button, the component implements this feature through an outer wrapper. When clearable is set, a delete icon is displayed on hover (only valid in single-selection mode).

html
<TuiSelectNative v-model="val" clearable :options="options" />

Icon

Icons can be added to the head of the selection box using the icon property.

html
<TuiSelectNative icon="tui-icon ti-star" v-model="val" :options="options" />

Size

Supports large, small, and default sizes.

html
<TuiSelectNative size="small" v-model="val1" :options="options" />
<TuiSelectNative size="large" v-model="val2" :options="options" />

API Reference

TuiSelectNative Props

PropertyTypeDefaultDescription
modelValueString/Number/Array-Bound value.
optionsArray[]Data source.
valueKeyString'value'The key name for the value in the option object.
labelKeyString'label'The key name for the label in the option object.
disabledKeyString'disabled'The key name for the disabled state in the option object.
multipleBooleanfalseWhether to enable multiple selection (native behavior).
disabledBooleanfalseWhether it is disabled.
clearableBooleanfalseWhether to show the clear button.
sizeStringnullSize. Options: large, small.
iconString-Header icon class name.
placeholderString-Placeholder (usually displayed as the first disabled option).
widthString/Number-Width.
requiredBooleanfalseNative required attribute.
autofocusBooleanfalseNative autofocus attribute.
nameString-Native name attribute.
idString-Native id attribute.
customClassString-Custom class name.

TuiSelectNative Emits

Event NameDescriptionCallback Parameters
update:modelValueTriggered when the bound value changes.(value)
changeTriggered when the option changes.(value)
focusTriggered when gaining focus.(event)
blurTriggered when losing focus.(event)
clearTriggered when the clear button is clicked.-

TuiSelectNative Methods (Expose)

Method NameDescription
focusMakes the selection box gain focus.
blurMakes the selection box lose focus.
getSelectElementGets the internal native select DOM element.
syncSelectedStateManually syncs the selected state.

TuiOptionNative Props

PropertyTypeDefaultDescription
valueString/Number/BooleanRequiredThe value of the option.
labelString/Number-The label of the option.
disabledBooleanfalseWhether it is disabled.
selectedBooleanfalseWhether it is selected.
customClassString-Custom class name.

Released under the MIT License.