Skip to content

FormCheckbox

Boolean checkbox with v-model. Supports a switch variant via themeVariant. The label text is set via the label-content prop or the named #label slot — there is no default slot.

bash
npm install @vuecs/form-controls

Basic usage

Bound: accepted=false, notifications=true

vue
<script setup lang="ts">
import { VCFormInputCheckbox } from '@vuecs/form-controls';
import { ref } from 'vue';

const accepted = ref(false);
const notifications = ref(true);
</script>

<template>
    <VCFormInputCheckbox v-model="accepted" label-content="I accept the terms" />

    <VCFormInputCheckbox
        v-model="notifications"
        label-content="Enable notifications"
        :theme-variant="{ variant: 'switch' }"
    />
</template>
css
/* Tailwind v4 + design tokens */
@import "tailwindcss";
@import "@vuecs/design";

/*
 * The switch variant is shipped as structural CSS in @vuecs/form-controls.
 * Without this import the variant prop applies the class but the switch
 * appearance is missing — looks identical to the default checkbox.
 */
@import "@vuecs/form-controls";

/* Class-based dark mode (optional — pairs with the tokens) */
@custom-variant dark (&:where(.dark, .dark *));

Custom label markup

Use the named #label slot to render the label as markup. The slot receives class (the resolved label class) and id (matching the input's for):

vue
<VCFormInputCheckbox v-model="accepted">
    <template #label="{ class: labelClass, id }">
        <label :class="labelClass" :for="id">
            I accept the <a href="/terms">terms</a>
        </label>
    </template>
</VCFormInputCheckbox>

Variants

Variant keyValuesDefaultDescription
variant'checkbox' | 'switch''checkbox'Render as a square checkbox or a toggle switch

The switch variant changes the visual presentation only — v-model still binds a boolean (or a value pushed onto an array when used with :group="true").

Behavioral defaults

KeyDefaultDescription
labelContent'Input'Label text when neither label-content prop nor #label slot is provided

Props

PropTypeDefaultDescription
modelValueboolean | any[]The checked state (boolean) or selected values (with :group)
valueany (via attrs)Value to push onto/remove from modelValue when :group="true"
groupbooleanfalseTreat modelValue as an array of selected values
labelbooleantrueRender the label wrapper. Set false to render only the bare <input>
labelContentstring(defaults system)Inline label text — bypasses the #label slot

See also

Released under the Apache 2.0 License.