Skip to content

Switch ​

Yorliqlar, belgilar, yuklash, asinxron tasdiqlash va moslashtirilgan qiymatlarga ega togl switch.

false
vue
<script setup lang="ts">
const value = ref(false)
</script>

<template>
  <VxSwitch v-model="value" />
</template>

With Label ​

vue
<template>
  <VxSwitch v-model="value" label="Enable notifications" />
  <VxSwitch v-model="value" label="Dark mode" description="Switch between themes" />
</template>

Active / Inactive Text ​

vue
<template>
  <VxSwitch active-text="On" inactive-text="Off" />
</template>

Inline Text ​

Yo‘l ichidagi matn.

vue
<template>
  <VxSwitch active-text="ON" inactive-text="OFF" inline-text />
</template>

Icons ​

vue
<template>
  <VxSwitch v-model="value">
    {{ value ? '🌙 Dark' : '☀️ Light' }}
  </VxSwitch>
</template>

Custom Colors ​

vue
<template>
  <VxSwitch active-color="#22c55e" />
  <VxSwitch active-color="#ef4444" inactive-color="#374151" />
</template>

Custom Values ​

Boolean bo‘lmagan qiymatlardan foydalaning.

v-model: "dark"
v-model: 1 (number)
vue
<template>
  <VxSwitch v-model="theme" active-value="dark" inactive-value="light" />
  <!-- v-model: "dark" or "light" -->

  <VxSwitch v-model="status" :active-value="1" :inactive-value="0" />
  <!-- v-model: 1 or 0 -->
</template>

Sizes ​

xssmdefaultlgxl
vue
<template>
  <VxSwitch size="xs" />
  <VxSwitch size="sm" />
  <VxSwitch />
  <VxSwitch size="lg" />
  <VxSwitch size="xl" />
</template>

Square ​

vue
<template>
  <VxSwitch square />
</template>

Loading ​

vue
<template>
  <VxSwitch v-model="value" loading />
</template>

Before Change (Async) ​

Almashtirishdan oldin tasdiq so‘rang.

true
vue
<script setup>
async function beforeChange() {
  return confirm('Are you sure?')
}
</script>

<template>
  <VxSwitch v-model="value" :before-change="beforeChange" />
</template>

Readonly ​

vue
<template>
  <VxSwitch :model-value="true" readonly />
</template>

Disabled ​

vue
<template>
  <VxSwitch disabled />
</template>

Reverse Layout ​

Switch’ni yorliqning o‘ng tomoniga joylashtiring.

vue
<template>
  <VxSwitch v-model="value" label="Wi-Fi" description="..." reverse />
</template>

Press Animation ​

Bosilganda thumb cho‘ziladi va taktil javob beradi. Effektni ko‘rish uchun yuqoridagi istalgan switch’ni bosib ushlab turib ko‘ring.

Props ​

PropTypeDefaultDescription
modelValueboolean | string | numberfalseQiymat (v-model)
activeValueboolean | string | numbertrueYoqilganidagi qiymat
inactiveValueboolean | string | numberfalseO‘chirilganidagi qiymat
disabledbooleanfalseO‘chirish
loadingbooleanfalseYuklash aylantirgichi
readonlybooleanfalseFaqat o‘qish
size'xs' | 'sm' | 'default' | 'lg' | 'xl''default'O‘lcham
activeColorstring''Yoqilgan rang
inactiveColorstring''O‘chirilgan rang
activeTextstring''Yoqilganidagi matn
inactiveTextstring''O‘chirilganidagi matn
activeIconComponent—Yoqilganidagi belgi (thumb ichida)
inactiveIconComponent—O‘chirilganidagi belgi (thumb ichida)
inlineTextbooleanfalseYo‘l ichida matnni ko‘rsatish
labelstring''Yorliq matni
descriptionstring''Yorliq ostidagi tavsif
squarebooleanfalseKvadrat shakl
beforeChange() => boolean | Promise<boolean>—Almashtirishdan oldingi asinxron tekshiruvchi
requiredbooleanfalseForma tekshiruvi uchun majburiy sifatida belgilash
reversebooleanfalseSwitch’ni o‘ng tomonga joylashtirish
trackClassstring | string[] | object—Yo‘l uchun moslashtirilgan class(lar)
thumbClassstring | string[] | object—Thumb uchun moslashtirilgan class(lar)

Events ​

EventTypeDescription
update:modelValue(v)Qiymat o‘zgardi
change(v)Qiymat o‘zgardi

Slots ​

SlotDescription
defaultMoslashtirilgan yorliq kontenti
descriptionMoslashtirilgan tavsif