Skip to content
nexubDesign System
v12.7.0

Components · Form Controls

Checkbox

StableAdded v0.0.1

Binary checkbox input built on Radix UI.

import { Checkbox } from '@nexub/react';
View as Markdown

Playground

Props

size
TSX
<Checkbox defaultChecked />

Examples

Default

With label

States

Sizes, invalid and read-only

size follows the shared sm / md / lg scale. invalid draws the error border and sets aria-invalid. readOnly stays focusable but cannot change.

States

  • default
  • disabled
  • invalid
  • readOnly
  • checked
  • size="sm"
  • size="md"
  • size="lg"

Props

Props
PropTypeDefaultDescription
checkedboolean—The controlled checked state.
defaultCheckedboolean—The initial checked state when uncontrolled.
disabledboolean—Disables the checkbox when true.
requiredboolean—Marks the checkbox as required in a form.
onCheckedChange(checked: boolean) => void—Callback fired when the checked state changes.
invalidboolean—Error border and aria-invalid.
readOnlyboolean—Focusable but cannot change; sets aria-readonly.
size'sm' | 'md' | 'lg''md'Box size: sm 16px, md 18px (default), lg 20px.

Design tokens

Checkbox reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Checkbox below it, and leave the roles other components share alone. See the three token tiers.

Checkbox design tokens
TokenAliasesNotes
--checkbox-checked-bg--color-primaryAlso the indeterminate fill.
--checkbox-checked-fg--color-on-primary—
--checkbox-border--color-outline—
--checkbox-radius5pxDefault: 0.3125rem
CSS
/* One area of your app */
.checkout {
  --checkbox-checked-bg: var(--color-secondary);
}