Skip to content

Select ​

Bitta/koʻp tanlash, qidiruv, guruhlar, teglar va klaviatura navigatsiyasi bilan dropdown select.

Pick a fruit...
vue
<script setup>
const value = ref(null)
const options = [
  { label: 'Apple', value: 'apple' },
  { label: 'Banana', value: 'banana' },
]
</script>

<template>
  <VxSelect v-model="value" :options="options" />
</template>

String Options ​

Select...
vue
<template>
  <VxSelect :options="['Red', 'Green', 'Blue']" />
</template>

Clearable ​

Banana
banana
vue
<template>
  <VxSelect v-model="value" :options="options" clearable />
</template>

Searchable ​

Search countries...
vue
<template>
  <VxSelect v-model="value" :options="options" searchable />
</template>

Multiple ​

Select fruits...
vue
<template>
  <VxSelect v-model="value" :options="options" multiple />
</template>

Multiple Searchable ​

Search & select...
vue
<template>
  <VxSelect v-model="value" :options="options" multiple searchable clearable />
</template>

Collapse Tags ​

Default (1 tag + N)
Select...
Show 3 tags
Select...
All tags (wrap)
Select...
vue
<template>
  <VxSelect multiple />
  <VxSelect multiple :max-tags="3" />
  <VxSelect multiple :collapse-tags="false" />
</template>

Grouped Options ​

Pick food...
vue
<script setup>
const options = [
  { label: 'Fruits', options: [
    { label: 'Apple', value: 'apple' },
    { label: 'Banana', value: 'banana' },
  ]},
  { label: 'Vegetables', options: [
    { label: 'Carrot', value: 'carrot' },
  ]},
]
</script>

<template>
  <VxSelect :options="options" />
</template>

Disabled Options ​

Some disabled...
vue
<template>
  <VxSelect :options="[{ label: 'Russia', value: 'ru', disabled: true }]" />
</template>

Sizes ​

Small
Default
Large
vue
<template>
  <VxSelect size="sm" />
  <VxSelect />
  <VxSelect size="lg" />
</template>

Loading ​

Variantlar yuklanayotgan vaqtda spinner’ni koʻrsating.

Loading options...
vue
<script setup>
const loading = ref(true)
const options = ref([])

onMounted(async () => {
  const res = await fetch('/api/options')
  options.value = await res.json()
  loading.value = false
})
</script>

<template>
  <VxSelect v-model="value" :options="options" :loading="loading" />
</template>

Katta variantlar roʻyxatida yaxshiroq ishlash uchun filtrlashni kechiktiradi.

Search 100 options (300ms debounce)...
vue
<template>
  <VxSelect :options="largeList" searchable :debounce="300" />
</template>
Search countries...
vue
<script setup>
async function fetchOptions(query, page) {
  const res = await fetch(`/api/search?q=${query}&page=${page}`)
  return res.json()
}
</script>

<template>
  <VxSelect :fetch-options="fetchOptions" searchable />
</template>

Paginated (Infinite Scroll) ​

Pastga scroll qilganda koʻproq variantlarni yuklaydi. Sahifalarni cheklash uchun page-count ni belgilang.

Scroll to load comments...
vue
<script setup>
async function fetchComments(query, page) {
  const res = await fetch(
    `https://jsonplaceholder.typicode.com/comments?_limit=10&_page=${page}`
  )
  const data = await res.json()
  return data.map(c => ({ label: c.name, value: c.id }))
}
</script>

<template>
  <VxSelect :fetch-options="fetchComments" :page-count="50" searchable />
  <!-- fetchOptions receives (query, page) — page starts from 1 -->
</template>

Creatable (Tag Input) ​

Yangi qiymatni kiriting va uni yaratish uchun Enter tugmasini bosing.

Type to add...
vue
<template>
  <VxSelect v-model="tags" :options="options" multiple searchable creatable />
</template>

Max Selection ​

Max 3 items
vue
<template>
  <VxSelect v-model="value" :options="options" multiple :max-selection="3" />
</template>

Keep Open After Select ​

Stays open...
vue
<template>
  <VxSelect multiple :close-on-select="false" />
</template>

Custom Option Slot ​

With flags...
vue
<template>
  <VxSelect :options="countries">
    <template #option="{ option, label, selected }">
      <span>{{ option.value.toUpperCase() }}</span>
      <span>{{ label }}</span>
      <CheckIcon v-if="selected" />
    </template>
  </VxSelect>
</template>

Disabled ​

Cherry
vue
<template>
  <VxSelect v-model="value" disabled />
</template>

Props ​

PropTypeDefaultDescription
modelValueanynullTanlangan qiymat(lar) (v-model)
options(SelectOption | SelectGroup | string)[][]Variantlar
placeholderstring'Select...'Placeholder
disabledbooleanfalseOʻchirish
clearablebooleanfalseTozalash tugmasi
searchablebooleanfalseQidiruv filtrini yoqish
multiplebooleanfalseKoʻp tanlash
collapseTagsbooleantrueKoʻp teglarni +N bilan yigʻish
maxTagsnumber1Yigʻishdan oldingi teglar soni
size'sm' | 'default' | 'lg''default'Oʻlcham
emptyTextstring'No options'Boʻsh holat matni
debouncenumber0Qidiruv filtrini kechiktirish (ms)
fetchOptions(query: string, page: number) => Promise<Option[]>—Asinxron qidiruv funksiyasi. page 1 dan boshlanadi
loadingbooleanfalseYuklash spinner’ini koʻrsatish
creatablebooleanfalseYangi variantlarni yaratishga ruxsat berish
closeOnSelectbooleanautoTanlagandan keyin yopish (auto: single uchun true, multi uchun false)
reserveKeywordbooleanfalseTanlagandan keyin qidiruv matnini saqlab qolish
defaultFirstOptionbooleanfalseBirinchi variantni avtomatik belgilash
maxSelectionnumber0Maksimal tanlovlar (0=cheklovsiz)
pageCountnumber0Pagination uchun maksimal sahifalar (0=paginationsiz)
scrollDistancenumber20Koʻproq yuklashni ishga tushirish uchun pastdan pixel
destroyOnClosebooleanfalseYopilganda kesh qilingan remote maʼlumotni tozalash
labelFieldstring'label'Maxsus label kaliti
valueFieldstring'value'Maxsus value kaliti
triggerClassstring''Maxsus trigger klassi
triggerStyleRecord<string, string>—Maxsus trigger uslubi

Events ​

EventTypeDescription
update:modelValue(v: any)Tanlov oʻzgardi
change(v: any)Tanlov oʻzgardi
search(query: string)Qidiruv matni oʻzgardi
create(value: string)Yangi variant yaratildi
loadMore(page: number)Keyingi sahifa soʻraldi

Slots ​

SlotPropsDescription
option{ option, label, value, selected }Maxsus variant render qilish
tag{ tag, remove }Maxsus teg render qilish
prefix—Trigger’dagi matndan oldin
suffix—Trigger’dagi matndan keyin
empty—Variantlar yoʻq kontenti