Skip to content

Checkbox

Basic Usage

checked.value === false
planet.value === ''
planets.value === []
vue
<script setup>
import { Checkbox } from '@8ctavio/vergil/components'
import { useModel } from '@8ctavio/vergil'
const checked = useModel(false)
const planet = useModel('')
const planets = useModel([])
</script>

<template>
    <!-- Single boolean value -->
    <Checkbox v-model="checked" label="Checkbox"/>

    <!-- Multiple values, single selection -->
    <Checkbox v-model="planet" value="earth" label="Earth"/>
    <Checkbox v-model="planet" value="reach" label="Reach"/>
    <Checkbox v-model="planet" value="harvest" label="Harvest"/>

    <!-- Multiple values, multiple selection -->
    <Checkbox v-model="planets" value="Arcadia" label="Arcadia"/>
    <Checkbox v-model="planets" value="requiem" label="Requiem"/>
    <Checkbox v-model="planets" value="sanghelios" label="Sanghelios"/>
</template>

Props

Checked value
value[-checked]: (boolean | string) = true

The value-checked prop is the value assigned to the Checkbox's model value when it gets checked, and the value of the underlying input[type="checkbox"] element's value attribute.

Unchecked value
value-unchecked: (boolean | string) = false

The value-unchecked prop is the value assigned to the Checkbox's model value when it gets unchecked. If value-checked is a string, value-unchecked defaults to an empty string ('').

Label
label: string
MiniMarkup

The label slot may be use instead. The slot content overrides the label prop.

Description
description: string
MiniMarkup

The description slot may be use instead. The slot content overrides the description prop.

vue
<Checkbox label="Label" description="Description"/>

Variant
variant: ('classic' | 'card' | 'list' | 'toggle') = 'classic'

Show symbol
show-symbol: boolean

Theme
theme: theme = 'brand'

Size
size: ('xs' | 'sm' | 'md' | 'lg' | 'xl') = 'md'

Radius
radius: ('none' | 'sm' | 'md' | 'lg' | 'full') = 'md'

Spacing
spacing: ('compact' | 'expanded') = ''

Disabled
disabled: boolean

Elements

elementtagdescription
input<input[type="checkbox"]>Checkbox's underlying input element.

Anatomy

<label.checkbox/>

<input[type="checkbox"]/>

<span.toggle-button/>

<svg.toggle-check/>

<p.toggle-label/>

<slot name="default"/>

<p.toggle-description/>

<slot name="description"/>

API Reference

Props

proptypedefault
checkedstring
valueboolean | stringundefined
valueCheckedboolean | stringtrue
valueUncheckedboolean | stringfalse
labelstring
descriptionstring
variant'classic' | 'card' | 'list' | 'toggle''classic'
showSymbolboolean
disabledboolean
descendantboolean
theme'brand' | 'user' | 'ok' | 'info' | 'warn' | 'danger' | 'neutral''brand'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
radius'none' | 'sm' | 'md' | 'lg' | 'full''md'
spacing'' | 'compact' | 'extended'''
validatorFunction
eagerValidationboolean
elementsobject

Configuration options

Checkbox's configuration options allow to overwrite some Checkbox props' default values and may be overwritten under the checkbox root-level configuration option.

checkbox.<option>typedefaultglobal
variant'classic' | 'card' | 'list' | 'toggle''classic'
themetheme
sizesize
radiusradius
spacingspacing