Inputs@knitui/components
Checkbox
Checkbox is a cross-platform toggle control. variant sets how the active colour ramp is applied; size scales the box, icon and label together. Compose Checkbox.Group for multi-select lists, Checkbox.Card for card-style toggles, and Checkbox.Indicator for a read-only presentational box.
import { Checkbox } from "@knitui/components";Usage
Pass a label and let it manage its own state, or drive it with
checked + onChange.
import { Checkbox } from "@knitui/components";
<Checkbox label="Accept terms and conditions" onChange={setAccepted} />;description and error render under the label and are wired to the control for
screen readers, so there is no separate helper-text component to place and label
yourself:
<Checkbox
label="Email me"
description="No more than once a week."
error="Pick at least one channel."
/>Three compositions cover the usual layouts:
Checkbox.Groupfor a set of related checkboxes with a shared value array.Checkbox.Cardfor card-shaped, clickable options.Checkbox.Indicatorfor a read-only box that shows state without being a control — useful inside a list row that is itself pressable.
indeterminate renders the mixed glyph, for a parent checkbox summarising
partially-selected children. It is presentational only: it does not change what
checked reports, so keep driving checked yourself.
When to use something else
- One of several mutually exclusive options →
Radio - An immediate on/off setting →
Switch - A compact, toggle-shaped filter →
Chip
Examples
Variants
Both visual variants at the default size, checked and unchecked.
Loading example…
Sizes
Full seven-step size scale.
Loading example…
Disabled
Disabled state — the box is dimmed and cannot be toggled.
Loading example…
Indeterminate
Indeterminate state — aria-checked is "mixed" to indicate partial selection.
Loading example…
With Label And Description
Label, description and error message rendered together.
Loading example…
Controlled
Controlled — checked state is owned by the parent; prints current value below.
Loading example…
Read Only
Read-only — the value is visible but cannot be changed.
Loading example…
Group
Checkbox.Group manages an array of selected values across multiple checkboxes.
Loading example…
Group Max Values
Checkbox.Group with a maximum number of selections enforced.
Loading example…
Card
Checkbox.Card renders a pressable card that functions as a checkbox.
Loading example…
Card Shadows
Checkbox.Card with the shadow elevation prop across the shadow ladder.
Loading example…
Indicator
Checkbox.Indicator is a presentational-only box with no press handler.
Loading example…
Themes
Accent themes use Tamagui theme, not a public color prop.
Loading example…
Matrix
Full variant × size matrix for visual regression.
Loading example…
Styles
Per-slot styles targets individual parts — here the box square and the label.
Loading example…
Props
| Prop | Type | Default | Description |
|---|---|---|---|
aria-describedby | string | undefined | — | Extra element id(s) to merge into the control's `aria-describedby`. |
checked | boolean | undefined | — | Controlled checked state. |
defaultChecked | boolean | undefined | false | Initial checked state for the uncontrolled case. |
description | ReactNode | — | Description rendered below the label. |
disabled system | boolean | undefined | false | Disables the checkbox. |
error | ReactNode | — | Error rendered below the description (string nodes get the error theme). |
icon | CheckboxIconComponent | undefined | — | Icon component for the checked / indeterminate state. |
iconColor | GetThemeValueForKey<"color"> | OpaqueColorValue | undefined | — | Override the icon colour (defaults to the contrast/accent colour). |
id | string | undefined | — | Id used to bind the control and label; auto-generated when omitted. |
indeterminate | boolean | undefined | false | Indeterminate state. When set, `checked` is ignored for display. |
label | ReactNode | Accept terms and conditions | Label content rendered next to the control. |
labelPosition | "left" | "right" | undefinedleft · right | 'right' | Position of the label relative to the checkbox box. |
onChange | ((checked: boolean) => void) | undefined | — | Called with the next checked state. Mirrors Mantine's `onChange` name; the payload is a boolean (not a DOM event) because the kit is cross-platform. |
onCheckedChange | ((checked: boolean) => void) | undefined | — | — |
radius system | string | number | undefined | — | — |
readOnly | boolean | undefined | false | If set, the value cannot be changed but the control stays focusable. |
rootRef | Ref<TamaguiElement> | undefined | — | Ref of the root wrapper element. |
shadow system | "xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined | — | — |
size system | "xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefinedxxs · xs · sm · md · lg · xl · xxl | 'md' | Controls the box dimensions, icon size and label metrics. |
styles system | SlotStyles<CheckboxStyles> | undefined | — | Uniform per-slot style passthrough — sugar over the composable parts. Own slots: `box` (the square) / `icon` (the glyph); plus the inherited chrome slots `label` / `description` / `error` / `root` forwarded to the `InlineControl`. |
theme system | ThemeName | null | undefinedunset · blue · red · green · yellow · pink · gray | — | Accent theme applied to the checkbox box and icon. |
value | string | undefined | — | Value reported to a surrounding `Checkbox.Group`. |
variant system | CheckboxVariant | undefinedfilled · outline | 'filled' | Visual style — filled fills the box with the accent colour; outline tints the border and icon only. |
withErrorStyles | boolean | undefined | true | Apply error styles to the box when `error` is set. |
Style slots
Every part of Checkbox can be styled through the styles prop. Explicit props on the component always win over slot styles.
| Slot | Targets |
|---|---|
box | Props for the square CheckboxBox. |
description | The description Text rendered below the label. |
error | The error Text rendered below the description. |
icon | Props for the check / indeterminate glyph (Checkbox.icon). |
label | The label Text. |
root | The outer InlineControlRoot row. |
Accessibility & DOM props (2)
| Prop | Type |
|---|---|
key | Key | null | undefined |
ref | Ref<TamaguiElement> | undefined |
Plus 496 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.
Accessibility
On the web the box carries role="checkbox" and aria-checked, which reports
"mixed" when indeterminate is set — the standard announcement for a partially
selected group.
Because the box is a styled Box rather than an <input type="checkbox">, it is
made focusable and operable through the kit's shared
useKeyboardActions hook: on the web that adds
tabIndex and key handling; on native it maps to platform accessibility actions.
| Key | Action |
|---|---|
| Tab | Move focus to the checkbox |
| Space / Enter | Toggle |
- Always give it a name.
labelis the simplest way; without one, passaria-labelor pointaria-labelledbyat your own text. descriptionanderrorare referenced througharia-describedby, so they are announced with the control rather than orphaned next to it.disabledsetsaria-disabledand takes the control out of the tab order (tabIndex="-1"), so it is announced as disabled rather than silently inert.readOnlyis different on purpose: the value cannot change but the control stays focusable, so a keyboard user can still read it.Checkbox.Grouprenders withrole="group"— give it a label so the set is announced as one thing.