Checkbox
Checkboxes allow the user to select one or more items from a list or set. Checkbox is an accessible Camp Next Gen component with support for labeled controls, default and large sizes, indeterminate visuals for parent rows, disabled and required states, and standard HTML form props. The authoritative package is @camp/checkbox.
Loading...
Loading...
Overview
Use this page with the Checkbox Playground in Storybook to explore props interactively. Variations below embed individual Canvas stories from Checkbox Chromatic Tests.
Resources
Install
yarn add @camp/checkboxProps
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | — | The initial state of the checkbox. The current state of the checkbox. |
onChange | ((event: ChangeEvent<HTMLInputElement>) => void) | ((event: ChangeEvent<HTMLInputElement>) => void) | — | Callback fired when the checkbox is changed. |
label | string | — | The label for the checkbox. Clicking the label also toggles the checkbox. |
indeterminate | boolean | — | Display the checkbox in an indeterminate state. (must be used with `checked` and `onChange` props) |
key † | Key | — | |
aria-label † | string | — | Defines a string value that labels the current element. @see aria-labelledby. |
disabled † | boolean | — | |
className † | string | — | |
aria-disabled † | Booleanish | — | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. @see aria-hidden @see aria-readonly. |
id † | string | — | |
name † | string | — | |
noMargin | boolean | — | Passed to Label; removes default bottom margin when embedded in dense layouts. |
style † | CSSProperties | — | |
value † | string | number | readonly string[] | — | |
size | "default" | "large" | default | Determines the size of the checkbox. |
themed | boolean | false | Whether the checkbox should follow light/dark theme modes. Defaults to false for easier upgrades in legacy components. |
Generated from @camp/checkbox@10.7.0 source, ordered by production usage. * required. † standard HTML attribute — all native attributes are supported; only those with production usage are listed.
Upgrading to Next Gen
🔄 Consolidated package: @camp/ai-checkbox and the AiCheckbox export are consolidated into @camp/checkbox with the Checkbox component. Prefer @camp/checkbox for all new usage.
🧩 Controlled indeterminate: indeterminate is only supported in the controlled shape: pass checked, onChange, and indeterminate together. Uncontrolled usage cannot set indeterminate (see types in @camp/checkbox).
Variations
Examples use Canvas stories derived from Components/Checkbox/Checkbox Tests/Checkbox Chromatic Tests (components-checkbox-checkbox-tests-checkbox-chromatic-tests--…). The overview above uses Components/Checkbox (components-checkbox) for autodocs and the Playground.
Playground
Use the Storybook Playground for interactive controls (label, checked, size default | large, indeterminate, disabled, and more).
import { Checkbox } from '@camp/checkbox';
<Checkbox label="Label" />;Default Size Checked
Use checked and onChange together whenever you manage selection in React state (required for predictable checked UI in controlled mode).
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Default Checkbox Controlled Checked"
checked={isChecked}
onChange={handleChange}
/>;Indeterminate Parent Row
Pass indeterminate with checked and onChange to render the indeterminate glyph—for example a “select all” control when child rows are mixed. Clearing indeterminate when you no longer need the mixed state restores the ordinary checked visuals.
import { Checkbox } from '@camp/checkbox';
<Checkbox label="Parent (mixed children)" checked={false} indeterminate onChange={handleChange} />
<Checkbox
label="Parent (reads as checked with indeterminate icon)"
checked
indeterminate
onChange={handleChange}
/>Disabled
Disabled checkboxes are not interactive. They can be shown unchecked or checked according to your data.
import { Checkbox } from '@camp/checkbox';
<Checkbox label="Disabled" disabled />
<Checkbox label="Disabled checked" disabled checked />Required
Use required when validation should enforce that the checkbox is checked (for example acceptance of terms).
import { Checkbox } from '@camp/checkbox';
<Checkbox label="Accept terms" required />;Large Size
Large checkboxes suit builder canvases and other layouts where selection is a primary focal action—set size="large". Large uses the same behavior as default; only scale and spacing differ.
import { Checkbox } from '@camp/checkbox';
<Checkbox label="Large Checkbox" size="large" />
<Checkbox label="Large checked" size="large" checked={checked} onChange={handleChange} />Production Examples
More states from @camp/checkbox's visual test stories, ranked by production
usage. Variations already documented above are not repeated here.
Default Disabled Indeterminate Unchecked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Default Checkbox Disabled Indeterminate Unchecked"
checked={false}
disabled
indeterminate
onChange={() => {}}
/>Default Disabled Indeterminate Checked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Default Checkbox Disabled Indeterminate Checked"
checked
disabled
indeterminate
onChange={() => {}}
/>Large Disabled Indeterminate Unchecked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Large Checkbox Disabled Indeterminate Unchecked"
checked={false}
disabled
indeterminate
onChange={() => {}}
size="large"
/>Large Disabled Indeterminate Checked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Large Checkbox Disabled Indeterminate Checked"
checked
disabled
indeterminate
onChange={() => {}}
size="large"
/>Large Controlled Indeterminate Unchecked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Large Checkbox Controlled Indeterminate Unchecked"
checked={false}
indeterminate
onChange={() => {}}
size="large"
/>Large Controlled Indeterminate Checked
import { Checkbox } from '@camp/checkbox';
<Checkbox
label="Large Checkbox Controlled Indeterminate Checked"
checked
indeterminate
onChange={() => {}}
size="large"
/>5 more variations in Storybook
Usage
Uncontrolled
Omit checked and onChange when you rely on native form behavior or defaultChecked.
Form Value
Use value for the underlying <input type="checkbox" /> when posting forms or grouping values.
import { Checkbox } from '@camp/checkbox';
<Checkbox name="terms" value="accepted" label="I agree to the terms" />;Best Practices
- Checkboxes should act independently; one option should not unexpectedly toggle another. The exception is an explicit select all control whose behavior is clear to users.
- When grouped, order options in a logical sequence (for example alphabetical or by task flow).
- Display multiple checkboxes vertically rather than tightly wrapping long rows.
- For more than roughly ten discrete options in one group, prefer a dropdown or multi-select pattern.
Content Guidelines
Checkbox labels should be concise, sentence case, and omit trailing punctuation unless you are quoting full sentences.
✅ DO
-
Create a campaign
-
Add a contact
-
Start a conversation
-
Read my report
🚫 DON’T
-
Create A Campaign.
-
Add A Contact.
-
Start A Conversation.
-
Read My Report.
Accessibility
Structure
- Checkbox renders a
Labelfrom@camp/formwithhtmlFortied to anidgenerated withuseIdfrom@camp/core, so clicking the text label activates the native control. - The native
input type="checkbox"retains focus semantics;requiredflows through toinputfor built-in constraint validation messaging.
Keyboard
Tab/Shift+Tabmove focus onto the checkbox.Spacetogglescheckedon the focused control (native checkbox behavior).

