Checkbox

A control that allows the user to toggle between checked and unchecked states.

Choose your interests

Installation

pnpm dlx cubix@latest add checkbox --base radix

Usage

Import
import { Checkbox } from "@/components/cubix/checkbox"
Example
<form>
  <fieldset>
    <legend>Choose your interests</legend>
    <div className="grid gap-2">
      <Checkbox id="ui" value="ui">UI</Checkbox>
      <Checkbox id="ux" value="ux">UX</Checkbox>
      <Checkbox id="uxresearch" value="uxresearch">UX Research</Checkbox>
    </div>
  </fieldset>
</form>

Examples

States

Use checked, indeterminate, and disabled states to communicate the current condition clearly.

With description

Compose the Checkbox with a label and description to build settings rows and consent controls.

Sizes

API Reference

Props

PropTypeDefaultDescription
checkedbooleanfalseControlled checked state of the checkbox. Use with `onCheckedChange`.
defaultCheckedbooleanfalseDefault checked state for uncontrolled usage.
onCheckedChange(checked: boolean) => void-Called with the next checked value whenever the checkbox is toggled.
requiredboolean-Adds the required attribute when validating as part of a group of checkboxes.
namestring-The name attribute passed when submitting a form as part of a group.
valuestringonThe value attribute passed when submitting a form as part of a group.
indeterminatebooleanfalseWhen true, shows the indeterminate state.
disabledbooleanfalseDisables the checkbox.
aria-invalidbooleanfalseWhen true, indicates the checkbox is in an invalid state.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
...propsReact.ComponentProps<'input'>-All native input attributes (id, form, tabindex, aria-*, ...) are forwarded to the rendered element.

Variants

PropTypeDefaultDescription
default--Checked state with primary background and foreground.
indeterminate--Visual indeterminate state. Use when the checkbox represents a partial selection (e.g. grouped options).
disabled--Disabled checkboxes cannot be interacted with.