Checkbox
Toggle state in forms
Checkbox provides accessible checked and indeterminate states with controlled or uncontrolled state on web and native.
Features
Indeterminate state support
Accessible, composable, and customizable
Sizing with controlled or uncontrolled state
Optional native HTML checkbox on web
Installation
Checkbox is already installed in tamagui, or you can install it independently:
yarn
npm
bun
pnpm
Usage
Headless usage
The useCheckbox hook provides all the state and accessibility props needed to build a custom checkbox with any styling solution:
yarn
npm
bun
pnpm
API reference
Checkbox
Checkbox extends View, inheriting all the
View props. Sizes come from the shared
Sizing ladder.
Props
size
'xs' | 'sm' | 'md' | 'lg' | 'xl'
A named size ("xs" to "xl", default "md") is a rung in the sizing ladder: the box is the ladder's square derivation at the rung's radius.
labelledBy
string
Set the aria-labelledby attribute.
name
string
Equivalent to input name.
value
string
Give it a value (for use in HTML forms).
checked
boolean
Control the input.
defaultChecked
boolean
Uncontrolled default value.
required
boolean
Sets aria-required.
native
boolean
Renders native checkbox input on web.
onCheckedChange
(checked: boolean | "indeterminate") => void
Callback that fires when the checkbox state is changed.
unstyled
boolean
Removes all default Tamagui styles.
activeStyle
StylePiece
Styles to apply when the checkbox is checked. Accepts a style() piece.
activeTheme
string | null
Theme to apply when the checkbox is checked. Set to null for no theme change.
Checkbox.Indicator
Checkbox.Indicator extends View, inheriting all the
View props, plus:
Props
activeStyle
StylePiece
Styles to apply when the indicator is active. Accepts a style() piece.
forceMount
boolean
Used to force mounting when more control is needed.
useCheckbox
The useCheckbox hook accepts three arguments:
CheckedState
The checkbox supports three states:
true- checkedfalse- unchecked'indeterminate'- indeterminate/mixed state (useful for “select all” patterns)
Props (first argument)
Props
labelledBy
string
Set aria-labelledby for accessibility.
disabled
boolean
Whether the checkbox is disabled.
name
string
Form input name for the hidden input.
value
string
Default:
"on"Form input value.
required
boolean
Whether the checkbox is required in a form.
onCheckedChange
(checked: CheckedState) => void
Called when checked state changes.
onPress
(event) => void
Called when checkbox is pressed (composed with internal handler).
State (second argument)
A tuple of [checked, setChecked] where:
checked: Current state (boolean | 'indeterminate')setChecked: React state setter function
Return value
| Property | Type | Description |
|---|---|---|
checkboxProps | object | Props to spread on your checkbox element (role, aria-checked, onPress, etc.) |
checkboxRef | Ref | Composed ref to attach to your checkbox element |
bubbleInput | ReactNode | null | Hidden input for form compatibility (render as sibling, web only) |
- Property
checkboxProps- Type
object- Description
- Props to spread on your checkbox element (role, aria-checked, onPress, etc.)
- Property
checkboxRef- Type
Ref- Description
- Composed ref to attach to your checkbox element
- Property
bubbleInput- Type
ReactNode | null- Description
- Hidden input for form compatibility (render as sibling, web only)
Source
v2-look Checkbox: token-based sizing, theme background/border/focus styling, disabled dimming, and a centered indicator over the unstyled @tamagui/ui Checkbox behavior. This is the exact source the registry ships — copy it into your app and the examples above import from your copy.
components/tamagui/Checkbox.tsxDependencies
yarn add @tamagui/checkbox @tamagui/coreExpects theme tokens: background, background-press, border-color, border-color-hover, border-color-press, outline-color.
Need raw behavior without any skin? tamagui/unstyled re-exports the @tamagui/ui primitives (advanced).