Knit UI
GitHub

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.Group for a set of related checkboxes with a shared value array.
  • Checkbox.Card for card-shaped, clickable options.
  • Checkbox.Indicator for 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…

VariantsSourceStorybook

Sizes

Full seven-step size scale.

Loading example…

SizesSourceStorybook

Disabled

Disabled state — the box is dimmed and cannot be toggled.

Loading example…

DisabledSourceStorybook

Indeterminate

Indeterminate state — aria-checked is "mixed" to indicate partial selection.

Loading example…

IndeterminateSourceStorybook

With Label And Description

Label, description and error message rendered together.

Loading example…

With Label And DescriptionSourceStorybook

Controlled

Controlled — checked state is owned by the parent; prints current value below.

Loading example…

ControlledSourceStorybook

Read Only

Read-only — the value is visible but cannot be changed.

Loading example…

Read OnlySourceStorybook

Group

Checkbox.Group manages an array of selected values across multiple checkboxes.

Loading example…

GroupSourceStorybook

Group Max Values

Checkbox.Group with a maximum number of selections enforced.

Loading example…

Group Max ValuesSourceStorybook

Card

Checkbox.Card renders a pressable card that functions as a checkbox.

Loading example…

CardSourceStorybook

Card Shadows

Checkbox.Card with the shadow elevation prop across the shadow ladder.

Loading example…

Card ShadowsSourceStorybook

Indicator

Checkbox.Indicator is a presentational-only box with no press handler.

Loading example…

IndicatorSourceStorybook

Themes

Accent themes use Tamagui theme, not a public color prop.

Loading example…

ThemesSourceStorybook

Matrix

Full variant × size matrix for visual regression.

Loading example…

MatrixSourceStorybook

Styles

Per-slot styles targets individual parts — here the box square and the label.

Loading example…

StylesSourceStorybook

Props

PropTypeDefaultDescription
aria-describedbystring | undefined—Extra element id(s) to merge into the control's `aria-describedby`.
checkedboolean | undefined—Controlled checked state.
defaultCheckedboolean | undefinedfalseInitial checked state for the uncontrolled case.
descriptionReactNode—Description rendered below the label.
disabled systemboolean | undefinedfalseDisables the checkbox.
errorReactNode—Error rendered below the description (string nodes get the error theme).
iconCheckboxIconComponent | undefined—Icon component for the checked / indeterminate state.
iconColorGetThemeValueForKey<"color"> | OpaqueColorValue | undefined—Override the icon colour (defaults to the contrast/accent colour).
idstring | undefined—Id used to bind the control and label; auto-generated when omitted.
indeterminateboolean | undefinedfalseIndeterminate state. When set, `checked` is ignored for display.
labelReactNodeAccept terms and conditionsLabel content rendered next to the control.
labelPosition"left" | "right" | undefined
left · 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 systemstring | number | undefined——
readOnlyboolean | undefinedfalseIf set, the value cannot be changed but the control stays focusable.
rootRefRef<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" | undefined
xxs · xs · sm · md · lg · xl · xxl
'md'Controls the box dimensions, icon size and label metrics.
styles systemSlotStyles<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 systemThemeName | null | undefined
unset · blue · red · green · yellow · pink · gray
—Accent theme applied to the checkbox box and icon.
valuestring | undefined—Value reported to a surrounding `Checkbox.Group`.
variant systemCheckboxVariant | undefined
filled · outline
'filled'Visual style — filled fills the box with the accent colour; outline tints the border and icon only.
withErrorStylesboolean | undefinedtrueApply 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.

SlotTargets
boxProps for the square CheckboxBox.
descriptionThe description Text rendered below the label.
errorThe error Text rendered below the description.
iconProps for the check / indeterminate glyph (Checkbox.icon).
labelThe label Text.
rootThe outer InlineControlRoot row.
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<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.

KeyAction
TabMove focus to the checkbox
Space / EnterToggle
  • Always give it a name. label is the simplest way; without one, pass aria-label or point aria-labelledby at your own text.
  • description and error are referenced through aria-describedby, so they are announced with the control rather than orphaned next to it.
  • disabled sets aria-disabled and takes the control out of the tab order (tabIndex="-1"), so it is announced as disabled rather than silently inert.
  • readOnly is different on purpose: the value cannot change but the control stays focusable, so a keyboard user can still read it.
  • Checkbox.Group renders with role="group" — give it a label so the set is announced as one thing.

Edit this page on GitHub