VisorVisor
ComponentsForm

Checkbox

An accessible checkbox for toggling a boolean value. Built on Radix UI.

Default

Checked

Indeterminate

Disabled

Installation

npx visor add checkbox

This copies two files into your project:

  • components/ui/checkbox/checkbox.tsx — the component
  • components/ui/checkbox/checkbox.module.css — the styles

Usage

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

<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
  <Checkbox id="terms" />
  <Label htmlFor="terms">Accept terms and conditions</Label>
</div>

API Reference

CheckboxProps

PropTypeDefaultDescription
checkedboolean | "indeterminate"Controlled checked state.
defaultCheckedbooleanDefault checked state for uncontrolled usage.
onCheckedChange(checked: boolean | "indeterminate") => voidCallback when the checked state changes.
disabledbooleanfalseDisables the checkbox.
requiredbooleanfalseMarks the checkbox as required for form validation.
classNamestringAdditional CSS class names to merge onto the element.

The component also accepts all standard <button> HTML attributes (Radix renders checkbox as a button).

Accessibility

  • Built on @radix-ui/react-checkbox for full WAI-ARIA compliance
  • Renders as role="checkbox" with aria-checked reflecting the current state (including "mixed" for indeterminate)
  • Always pair with a <Label> using matching id/htmlFor for screen reader association
  • Keyboard: Space toggles the checkbox; Tab moves focus to/from it
  • Disabled state sets aria-disabled="true" and removes interaction