Keyboard shortcut: Ctrl + K
Get started

Checkbox

Use VCheckbox for independent choices or confirmation, such as accepting terms.

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VCheckbox } from 'vectis-ui'

const subscribed = ref(true)
</script>

<template>
  <VCheckbox v-model="subscribed">Send me release notes</VCheckbox>
</template>

Examples

Hint

Use label or the default slot for the name. hint adds help text linked through aria-describedby.

vue

A summary of the week, every Monday.

Only when someone names you.

<script setup lang="ts">
import { ref } from 'vue'
import { VCheckbox } from 'vectis-ui'

const digest = ref(true)
const mentions = ref(false)
</script>

<template>
  <div class="stack">
    <VCheckbox v-model="digest" label="Weekly digest" hint="A summary of the week, every Monday." />
    <VCheckbox v-model="mentions" label="Mentions" hint="Only when someone names you." />
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-3);
}
</style>

Label position

labelPosition="start" places the label before the checkbox.

vue
<script setup lang="ts">
import { VCheckbox } from 'vectis-ui'
</script>

<template>
  <div class="stack">
    <VCheckbox>Label after the box, the default</VCheckbox>
    <VCheckbox label-position="start">Label before the box</VCheckbox>
  </div>
</template>

<style scoped>
/* Keep the clickable label from stretching across the grid. */
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
</style>

Full width

spread fills the available width and places the label and checkbox at opposite ends.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VCheckbox } from 'vectis-ui'

const analytics = ref(true)
const crashes = ref(false)
</script>

<template>
  <div class="settings">
    <VCheckbox v-model="analytics" spread>Share anonymous usage data</VCheckbox>
    <VCheckbox v-model="crashes" spread label-position="start">Send crash reports</VCheckbox>
  </div>
</template>

<style scoped>
.settings {
  display: grid;
  gap: var(--vectis-space-3);
  inline-size: 100%;
  max-inline-size: 24rem;
  padding: var(--vectis-space-4);
  border: 1px solid var(--vectis-color-border);
  border-radius: var(--vectis-radius-surface);
}
</style>

Indeterminate

indeterminate indicates a partial selection, such as some items in a list being checked. It does not change the boolean v-model.

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

const scopes = ref([
  { label: 'Read', granted: true },
  { label: 'Write', granted: false },
  { label: 'Delete', granted: false },
])

const all = computed({
  get: () => scopes.value.every((scope) => scope.granted),
  set: (value: boolean) => {
    scopes.value.forEach((scope) => {
      scope.granted = value
    })
  },
})

const some = computed(() => scopes.value.some((scope) => scope.granted) && !all.value)
</script>

<template>
  <div class="tree">
    <VCheckbox v-model="all" :indeterminate="some">Permissions</VCheckbox>
    <div class="children">
      <VCheckbox v-for="scope in scopes" :key="scope.label" v-model="scope.granted">
        {{ scope.label }}
      </VCheckbox>
    </div>
  </div>
</template>

<style scoped>
.tree,
.children {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
.children {
  padding-inline-start: var(--vectis-space-6);
}
</style>

Read-only

readonly prevents changes by click or Space while preserving focus and native form behavior. A read-only, unchecked field with required still fails native form validation.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VCheckbox } from 'vectis-ui'

const on = ref(true)
const off = ref(false)
</script>

<template>
  <div class="stack">
    <VCheckbox v-model="on" readonly label="Set by your organisation" />
    <VCheckbox v-model="off" readonly label="Not available on your plan" />
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-3);
}
</style>

Disabled

disabled prevents changes and removes the checkbox from Tab navigation and form submission.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VCheckbox } from 'vectis-ui'

const off = ref(false)
const on = ref(true)
</script>

<template>
  <div class="stack">
    <VCheckbox v-model="off" disabled>Unticked</VCheckbox>
    <VCheckbox v-model="on" disabled>Ticked</VCheckbox>
    <VCheckbox v-model="off" disabled indeterminate>Partially ticked</VCheckbox>
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
</style>

API

Props

PropTypeDefault
labelstringnone
Visible label, replaced by the default slot. Without either, provide aria-label or aria-labelledby.
hintstringnone
Help text below the label, linked through aria-describedby.
errorstringnone
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears.
indeterminatebooleanfalse
Displays a partial-selection state. Independent of v-model, which remains a boolean.
labelPositionCheckboxLabelPosition'start' | 'end''end'
Label before the checkbox with start, or after it with end.
spreadbooleanfalse
Fills the available width and separates the label and checkbox.
invalidbooleanfalse
Sets aria-invalid and the error style. Does not block form submission by itself.
disabledbooleanfalse
Disables the checkbox and excludes it from focus and form submission.
readonlybooleanfalse
Prevents changes while keeping the checkbox focusable. Sets aria-readonly; native form submission and validation still apply.
v-modelbooleanfalse
Checked state, a boolean defaulting to false. Use native name and value attributes for form submission.

Slots

SlotType
default{}
Clickable label content, replacing label.

CSS variables

TokenValue
--vectis-control-size-check1.25rem
--vectis-control-size-check-mark0.875rem