Skip to content

Select

A customizable dropdown select component. Supports v-model binding, filtering options, and clearable state.


Basic Usage

The broadly applicable basic radio v-model takes the value of the currently selected option as its value attribute.

<script setup>
import { ref } from 'vue'
import Select from '@/components/Select/Select.vue'

const value = ref('')
const options = ref([
  { label: 'Option 1', value: 1 },
  { label: 'Option 2', value: 2 },
  { label: 'Option 3', value: 3 }
])
</script>

<template>
  <Select v-model="value" :options="options" placeholder="Please choose" />
</template>

Clearable

You can clear the selector by setting the clearable property.

<script setup>
import { ref } from 'vue'
import Select from '@/components/Select/Select.vue'

const value = ref(2)
const options = ref([
  { label: 'Apple', value: 1 },
  { label: 'Banana', value: 2 },
  { label: 'Orange', value: 3 }
])
</script>

<template>
  <Select 
    v-model="value" 
    :options="options" 
    placeholder="Choose fruits"
    clearable
  />
</template>

Filterable

You can use the filter functionality to quickly find options.

<script setup>
import { ref } from 'vue'
import Select from '@/components/Select/Select.vue'

const value = ref('')
const options = ref([
  { label: 'JavaScript', value: 'js' },
  { label: 'TypeScript', value: 'ts' },
  { label: 'Python', value: 'py' },
  { label: 'Java', value: 'java' }
])
</script>

<template>
  <Select
    v-model="value"
    :options="options"
    placeholder="Fuzzy search"
    filterable
  />
</template>

Select Attributes

NameDescriptionTypeDefault
modelValueThe bound valuestring | number
optionsThe options to select fromSelectOption[][]
placeholderPlaceholder for the inputstring''
disabledDisable the selectbooleanfalse
clearableWhether to show a clear iconbooleanfalse
filterableWhether to enable option filteringbooleanfalse

Select Events

NameDescriptionParameters
update:modelValueEmitted when selected value changes(value: string | number)
changeEmitted after value changed(value: string | number)
clearEmitted when the input is cleared
visible-changeEmitted when dropdown visibility toggles(visible: boolean)

Type Definition

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