Skip to content

Checkbox ​

Checkbox for toggling boolean values or selecting multiple options from a set.

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 ​

Use VxCheckboxGroup with v-model as an array to manage multiple selections.

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 ​

Used for "select all" patterns where some children are checked.

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 ​

Restrict the number of selections in a group with min and max.

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 ​

Use columns for a grid layout.

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—Checked state or array of values (v-model)
valuestring | number | boolean—Value when used in a group
labelstring''Label text
descriptionstring''Description below label
disabledbooleanfalseDisable checkbox
readonlybooleanfalseRead-only state
loadingbooleanfalseLoading state
size'sm' | 'default' | 'lg''default'Size
namestring''Input name attribute
borderedbooleanfalseShow border around checkbox
colorstring''Custom check color
indeterminatebooleanfalseShow indeterminate dash

CheckboxGroup Props ​

PropTypeDefaultDescription
modelValuearray[]Selected values (v-model)
optionsCheckboxOption[]—Options array
disabledbooleanfalseDisable all checkboxes
readonlybooleanfalseRead-only
size'sm' | 'default' | 'lg''default'Size for all checkboxes
direction'horizontal' | 'vertical''vertical'Layout direction
borderedbooleanfalseBordered style
colorstring''Custom color for all
namestring''Input name
columnsnumber0Grid columns (0 = flex)
gapstring''Custom gap
minnumber0Minimum selections required
maxnumber0Maximum selections allowed

Events ​

EventTypeDescription
update:modelValue(value)Value changed
change(value)Value changed

Slots ​

SlotDescription
defaultCustom label content
descriptionCustom description

CheckboxOption Interface ​

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