Checkbox
Pre-alphaThe registry and the CLI are not published yet.Roadmap

Checkbox

Checkbox with checked, unchecked and indeterminate states.

Packing list
Toiletries2 of 3
Toothbrush
Sunscreen
Razor
Documents0 of 2

Passport · already packed

Visa · not required

Installation

npx axiom add checkbox
pnpm dlx axiom add checkbox
yarn dlx axiom add checkbox
bun x axiom add checkbox

Requires the check and minus icons in your icon registry.

Usage

import { Checkbox } from '@/components/ui/checkbox';

<Checkbox checked={accepted} onCheckedChange={setAccepted} label="I accept the terms" />
<Checkbox checked="indeterminate" />

Props

PropTypeDefaultDescription
checkedboolean | 'indeterminate'Current state. 'indeterminate' draws a dash, for a parent whose children are partly checked.
defaultCheckedbooleanfalseInitial state when the checkbox manages its own state.
onCheckedChange(checked: boolean) => voidCalled with the new state. Pressing an indeterminate checkbox calls it with true.
labelReactNodeText next to the box. The whole row becomes pressable, not only the 22pt box.
descriptionReactNodeSecondary text under the label.
disabledbooleanfalseBlocks changes and uses the disabled tokens.
errorbooleanfalseRed border, for a required checkbox left unchecked on submit.
accessibilityLabelstringlabel textRequired when there is no label.
styleStyleProp<ViewStyle>Extra styles for the pressable row.

Box and check colors come from checkbox.default.{default,checked,invalid,disabled} in the component tokens.

Use cases

A required checkbox with its explanation as the label. error shows when the user submits without checking it.

I agree to the Terms and Privacy Policy

Required to create an account.

Send me product updates

Create account

<Checkbox
	checked={accepted}
	onCheckedChange={setAccepted}
	error={submitted && !accepted}
	label={
		<Text>
			I agree to the <Link href="/terms">Terms</Link>
		</Text>
	}
	description={
		submitted && !accepted ? "Required to create an account." : undefined
	}
/>

Select all in a list

The header checkbox is true, false or 'indeterminate' depending on how many rows are checked.

Cancel

2 selected

Delete

Select all
IMG_0142.HEIC3.1 MB
IMG_0143.HEIC2.8 MB
Screen Recording.mov48 MB
const all = selected.size === files.length;
const some = selected.size > 0 && !all;

<Checkbox
	label="Select all"
	checked={all ? true : some ? "indeterminate" : false}
	onCheckedChange={(v) =>
		setSelected(v ? new Set(files.map((f) => f.id)) : new Set())
	}
/>;

Filters with several choices

Checkboxes when any number of options can be on at once. For exactly one, use Radio.

CuisineReset
Italian24
Japanese18
Lebanese7
Mexican11

Show 31 places

{
	cuisines.map((c) => (
		<Checkbox
			key={c.id}
			label={c.name}
			checked={filters.has(c.id)}
			onCheckedChange={(v) => toggleFilter(c.id, v)}
		/>
	));
}