Skip to content

Checkbox ​

Boolean qiymatlarni almashtirish yoki to'plamdan bir nechta variantni tanlash uchun checkbox.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VxCheckbox } from 'veloxui'

const accepted = ref(false)
</script>

<template>
  <VxCheckbox v-model="accepted" label="Accept terms" />
</template>

With Description ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const marketing = ref(false)
const security = ref(true)
</script>

<template>
  <VxCheckbox
    v-model="marketing"
    label="Marketing emails"
    description="Receive updates about new products and features"
  />
  <VxCheckbox
    v-model="security"
    label="Security alerts"
    description="Get notified about security issues"
  />
</template>

Checkbox Group ​

Bir nechta tanlovlarni boshqarish uchun v-model ni massiv sifatida VxCheckboxGroup bilan ishlating.

Selected: [ "apple", "banana" ]
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VxCheckboxGroup } from 'veloxui'

const fruits = [
  { label: 'Apple', value: 'apple' },
  { label: 'Banana', value: 'banana' },
  { label: 'Cherry', value: 'cherry', disabled: true },
  { label: 'Grape', value: 'grape' },
]
const selected = ref(['apple', 'banana'])
</script>

<template>
  <VxCheckboxGroup v-model="selected" :options="fruits" />
</template>

Group with Descriptions ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const frameworks = [
  { label: 'React', value: 'react', description: 'A JavaScript library for building UIs' },
  { label: 'Vue', value: 'vue', description: 'The Progressive JavaScript Framework' },
  { label: 'Angular', value: 'angular', description: 'Platform for building mobile & desktop apps' },
]
const selected = ref(['react'])
</script>

<template>
  <VxCheckboxGroup v-model="selected" :options="frameworks" />
</template>

Horizontal Direction ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const selected = ref(['a', 'b'])
</script>

<template>
  <VxCheckboxGroup v-model="selected" :options="fruits" direction="horizontal" />
</template>

Bordered ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const selected = ref([])
</script>

<template>
  <VxCheckboxGroup v-model="selected" :options="fruits" direction="horizontal" bordered />
</template>

Sizes ​

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

Indeterminate ​

Ba'zi bolalari belgilangan "barchasini tanlash" naqshlari uchun ishlatiladi.

vue
<script setup lang="ts">
import { ref, computed } from 'vue'

const items = ['A', 'B', 'C', 'D']
const selected = ref(['A', 'C'])

const allChecked = computed(() => selected.value.length === items.length)
const indeterminate = computed(() => selected.value.length > 0 && !allChecked.value)

function toggleAll() {
  selected.value = allChecked.value ? [] : [...items]
}
</script>

<template>
  <VxCheckbox
    :model-value="allChecked"
    :indeterminate="indeterminate"
    label="Select all"
    @change="toggleAll"
  />
</template>

Custom Color ​

vue
<template>
  <VxCheckbox :model-value="true" label="Green" color="#22c55e" />
  <VxCheckbox :model-value="true" label="Blue" color="#3b82f6" />
  <VxCheckbox :model-value="true" label="Purple" color="#8b5cf6" />
</template>

Min / Max Selection ​

Guruhdagi tanlovlar sonini min va max bilan cheklang.

Min 1, Max 2. Selected: [ "node" ]
vue
<script setup lang="ts">
import { ref } from 'vue'

const selected = ref(['node'])
</script>

<template>
  <VxCheckboxGroup
    v-model="selected"
    :options="options"
    :min="1"
    :max="2"
    direction="horizontal"
  />
</template>

Grid Layout ​

Grid layout uchun columns dan foydalaning.

vue
<script setup lang="ts">
import { ref } from 'vue'

const sizes = ref(['sm'])
</script>

<template>
  <VxCheckboxGroup
    v-model="sizes"
    :options="options"
    :columns="3"
    gap="10px"
    bordered
  />
</template>

Disabled & Readonly ​

vue
<template>
  <VxCheckbox :model-value="true" label="Disabled" disabled />
  <VxCheckbox :model-value="true" label="Readonly" readonly />
</template>

Checkbox Props ​

PropTypeDefaultDescription
modelValueboolean | array—Belgilangan holat yoki qiymatlar massivi (v-model)
valuestring | number | boolean—Guruhda ishlatilganda qiymat
labelstring''Yorliq matni
descriptionstring''Yorliq ostidagi tavsif
disabledbooleanfalseCheckbox ni o'chirish
readonlybooleanfalseFaqat o'qish uchun holat
loadingbooleanfalseYuklash holati
size'sm' | 'default' | 'lg''default'O'lcham
namestring''Input ning name atributi
borderedbooleanfalseCheckbox atrofida chegarani ko'rsatish
colorstring''Moslashtirilgan belgi rangi
indeterminatebooleanfalseNoaniq chiziqchani ko'rsatish

CheckboxGroup Props ​

PropTypeDefaultDescription
modelValuearray[]Tanlangan qiymatlar (v-model)
optionsCheckboxOption[]—Variantlar massivi
disabledbooleanfalseBarcha checkbox larni o'chirish
readonlybooleanfalseFaqat o'qish uchun
size'sm' | 'default' | 'lg''default'Barcha checkbox lar uchun o'lcham
direction'horizontal' | 'vertical''vertical'Layout yo'nalishi
borderedbooleanfalseChegarali uslub
colorstring''Hammasi uchun moslashtirilgan rang
namestring''Input nomi
columnsnumber0Grid ustunlari (0 = flex)
gapstring''Moslashtirilgan oraliq
minnumber0Talab qilinadigan minimal tanlovlar
maxnumber0Ruxsat etilgan maksimal tanlovlar

Events ​

EventTypeDescription
update:modelValue(value)Qiymat o'zgardi
change(value)Qiymat o'zgardi

Slots ​

SlotDescription
defaultMoslashtirilgan yorliq mazmuni
descriptionMoslashtirilgan tavsif

CheckboxOption Interface ​

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