Components · Form Controls
Checkbox
Binary checkbox input built on Radix UI.
import { Checkbox } from '@nexub/react';Playground
Props
<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
defaultdisabledinvalidreadOnlycheckedsize="sm"size="md"size="lg"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | The controlled checked state. |
| defaultChecked | boolean | — | The initial checked state when uncontrolled. |
| disabled | boolean | — | Disables the checkbox when true. |
| required | boolean | — | Marks the checkbox as required in a form. |
| onCheckedChange | (checked: boolean) => void | — | Callback fired when the checked state changes. |
| invalid | boolean | — | Error border and aria-invalid. |
| readOnly | boolean | — | 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.
| Token | Aliases | Notes |
|---|---|---|
| --checkbox-checked-bg | --color-primary | Also the indeterminate fill. |
| --checkbox-checked-fg | --color-on-primary | — |
| --checkbox-border | --color-outline | — |
| --checkbox-radius | 5px | Default: 0.3125rem |
/* One area of your app */
.checkout {
--checkbox-checked-bg: var(--color-secondary);
}On iOS & Android: Checkbox
import { Checkbox } from '@nexub/react-native';
<Checkbox label="Remember this device" defaultChecked />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Label | Compose Label + control + HelperText (or FormField). | One component: label, helperText and error are props. |
| In lists | Checkbox + label. | Prefer ListItem variant="checkbox": one row, one target. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
Checkbox props
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | string | — | — |
| checked | boolean | — | — |
| defaultChecked | boolean | false | — |
| onCheckedChange | (checked: boolean) => void | — | — |
| description | string | — | — |
| disabled | boolean | — | — |
| size | Extract<ControlSize, 'sm' | 'md' | 'lg'> | 'md' | Box and label size, the same names as web Checkbox: sm, md, lg. |
| invalid | boolean | — | Red box and announced as invalid. |
| readOnly | boolean | — | Can be focused and read but not changed: pressing it does nothing. |
| accessibilityHint | string | description | What screen readers say after the label. |
| style | StyleProp<ViewStyle> | — | — |