Skip to content

Select

Select allows users to pick a value from a set of predefined options. Supports single select, multi-select, disabled options, and input group modes.

Basic Usage

Two-way binding via v-model. The options prop accepts object arrays { value, label } or plain string/number arrays.

Show Code
vue

<TSelect :options="fruitOptions" placeholder="Select a fruit"/>
<TSelect :options="cityOptions" placeholder="Select a city"/>

Sizing

Use the size prop to control the select size: 'lg' (large), default (medium), 'sm' (small).

Show Code
vue

<TSelect size="lg" :options="fruitOptions" placeholder="Large"/>
<TSelect :options="fruitOptions" placeholder="Default"/>
<TSelect size="sm" :options="fruitOptions" placeholder="Small"/>

States

Supports disabled and validation states. Pair with .valid-feedback / .invalid-feedback for validation messages.

Show Code
vue

<TSelect disabled :options="fruitOptions" placeholder="Disabled"/>
<TSelect validation="valid" :options="fruitOptions" placeholder="Valid"/>
<div class="valid-feedback">Looks good!</div>

<TSelect validation="invalid" :options="fruitOptions" placeholder="Invalid"/>
<div class="invalid-feedback">Please select an option.</div>

Option Disabled

Use the disabled field in option objects to disable specific options.

Show Code
vue

<TSelect :options="[
  { value: 'opt1', label: 'Option 1' },
  { value: 'opt2', label: 'Option 2' },
  { value: 'opt3', label: 'Option 3 (disabled)', disabled: true },
  { value: 'opt4', label: 'Option 4' },
]" placeholder="Select..." />

Multi-Select

Set multiple to enable multi-select mode. The v-model binding value becomes an array.

Show Code
vue

<TSelect multiple :options="cityOptions" />

Input Groups

Use prepend-text / append-text to add text prefixes/suffixes, or use #prepend / #append slots for custom content.

Show Code
vue

<TSelect prepend-text="Protocol" :options="['HTTP', 'HTTPS', 'FTP']"/>
<TSelect append-text="USD" :options="['100', '200', '500']"/>
<TSelect placeholder="Select action">
  <template #prepend>
    <span class="input-group-text">Action</span>
  </template>
  <option value="view">View</option>
  <option value="edit">Edit</option>
</TSelect>

Custom Options

When neither the options prop nor the default slot is provided, the select renders with no options. Use the default slot to pass native <option> elements for complete customization.

Two-Way Binding

v-model supports string, number, and string[] (for multi-select) types.

Show Code
vue

<script setup lang="ts">
  import { ref } from 'vue'
  const value = ref('')
</script>
<template>
  <p>Current value: {{ value }}</p>
  <TSelect v-model="value" :options="cityOptions" placeholder="Select a city" />
</template>

API

TSelect Props

PropDescriptionTypeDefault
optionsOption array (objects or strings/numbers)(SelectOption | string | number)[]undefined
placeholderPlaceholder textstringundefined
sizeSelect size'sm' | 'lg'undefined
disabledDisabled statebooleanfalse
multipleMulti-select modebooleanfalse
validationValidation state'valid' | 'invalid'undefined
blockFull width (w-100)booleanfalse
nameNative name attributestringundefined
idNative id attributestringundefined
requiredWhether requiredbooleanfalse
prepend-textPrepend textstringundefined
append-textAppend textstringundefined

TSelect Option Type (SelectOption)

ts
interface SelectOption {
  value: string | number
  label: string
  disabled?: boolean
}

TSelect Emits

EventDescriptionCallback
update:modelValueTriggered when selected value changes(value: string | number | string[]) => void

TSelect Slots

SlotDescription
defaultCustom option content (native <option> / <optgroup>)
prependPrepend content (replaces prepend-text), appears before <select>
appendAppend content (replaces append-text), appears after <select>