Veil UI
Components

Checkbox

A binary or indeterminate control built on Radix Checkbox.

Installation

$ npx veil-ui@latest add checkbox

Usage

import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";

<div className="flex items-center gap-2">
  <Checkbox id="terms" />
  <Label htmlFor="terms">Accept terms</Label>
</div>;

Examples

Basic

Indeterminate

Disabled

API reference

The package exports checkbox along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Checkbox renders a Radix checkbox with role="checkbox", supports the indeterminate state and receives focus styles through the wrapper.
  • Error and disabled states are exposed through native attributes and Radix data attributes.
  • Focus-visible rings follow the shared token system in both themes.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add checkbox --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { CheckboxIndicator, CheckboxRoot } from "reka-ui";
import { Check, Minus } from "lucide-vue-next";

import { cn } from "@/lib/utils";

const props = defineProps<{ class?: string; disabled?: boolean }>();

const model = defineModel<boolean | "indeterminate">({ default: false });
</script>

<template>
  <CheckboxRoot
    v-model="model"
    data-slot="checkbox"
    :disabled="disabled"
    :class="
      cn(
        'peer size-4 shrink-0 rounded-sm border border-input shadow-xs outline-none transition-[color,background-color,border-color,box-shadow]',
        'focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
        'disabled:cursor-not-allowed disabled:opacity-50',
        'aria-invalid:border-destructive aria-invalid:ring-destructive/20',
        'data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
        'data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground',
        props.class,
      )
    "
  >
    <CheckboxIndicator
      data-slot="checkbox-indicator"
      class="flex items-center justify-center text-current"
    >
      <Minus v-if="model === 'indeterminate'" class="size-3.5" />
      <Check v-else class="size-3.5" />
    </CheckboxIndicator>
  </CheckboxRoot>
</template>

On this page