Skip to main content

Checkbox

Stable

Toggles a boolean or indeterminate selection. Checkmark animates in with spring easing. First-class indeterminate support for select-all table patterns.

Form elementInteractiveVhyxSeal

Interactive example

Unchecked
Click to toggle

Import

tsx
import { Checkbox } from '@vhyxui/react'

States

UncheckedCheckedIndeterm.Disabled
All three states
Select all

State: Some selected

Select-all pattern with indeterminate

Sizes

sm, md, lg

Props

PropTypeDefaultDescription
checkedboolean | 'indeterminate'Controlled checked state.
defaultCheckedboolean | 'indeterminate'falseDefault state for uncontrolled usage.
onCheckedChange(checked: boolean | 'indeterminate') => voidCalled when the checked state changes.
indeterminatebooleanfalseForces the indeterminate (dash) state.
size'sm' | 'md' | 'lg''md'Size of the checkbox.
disabledbooleanfalseDisables interaction (from HTMLButtonElement).
asChildbooleanfalseRenders as the child element via Slot.
contractPartial<ComponentContract>VhyxSeal contract override.
classNamestringAdditional CSS classes appended to the checkbox.

Also accepts all standard HTMLButtonElement attributes.

Accessibility

  • Renders as <button role="checkbox"> for full CSS styling control.
  • aria-checked="mixed" set automatically for the indeterminate state.
  • Focus ring via :focus-visible — visible on keyboard, hidden on mouse click.
  • Always provide aria-label or use with Field for label association.

Keyboard navigation

KeyAction
SpaceToggle checked ↔ unchecked. Indeterminate → checked.
TabMove focus to the next focusable element.
Shift + TabMove focus to the previous focusable element.

Agent contract

Default VhyxSeal contract shipped with every Checkbox.

Default contract
{
  "type": "input",
  "intent": "toggle-selection",
  "description": "Toggles a boolean selection — checked, unchecked, or indeterminate",
  "requires": [],
  "requiredPermissions": [],
  "consequence": "Updates the checked state in the parent form context",
  "affects": [
    "form"
  ],
  "reversible": true,
  "safetyLevel": "low",
  "requiresConfirmation": false,
  "destructive": false,
  "contractVersion": "0.0.1",
  "fingerprint": "vhyxs_1cf17714"
}

Theming

Override these CSS tokens to theme Checkbox.

--vhyx-color-accentChecked background color
--vhyx-color-accent-hoverChecked hover background
--vhyx-color-border-strongUnchecked border color
--vhyx-color-surfaceUnchecked background
--vhyx-radius-smBorder radius
--vhyx-duration-fastCheckmark animation duration
--vhyx-easing-springCheckmark animation easing
--vhyx-shadow-focusFocus ring

Examples

Terms acceptance

I accept the terms and conditions
Checkbox with inline label

Inside a Field

tsx
<Field name="terms" label="Terms">
  <Checkbox
    {...form.register('terms')}
    checked={form.watch('terms')}
    onCheckedChange={v => form.setValue('terms', v === true)}
    aria-label="Accept terms and conditions"
  />
</Field>