Checkbox
A box that fills and draws its check on, morphs to a dash when mixed, sits on the label's first line, and a group with a tri-state parent, a limit and ★ hold-and-drag ticking.
npx @swipeui/cli add checkboxWhen to use it
- Agreeing to terms, opting into emails or confirming you've read something.
- Lists where people can pick several items, such as a shopping list or a list of permissions.
- Select-all controls that show a mixed state when only some items are chosen.
- Settings that are saved later with a Save button.
When not to use it
- Settings that take effect immediately. Use Switch.
- Picking exactly one option. Use Radio group.
- Filters shown as pills. Use Chip or Chip group.
- Marking a task done inside a card. Task card already includes one.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add checkbox- Adds
components/swipeui/ui/checkbox.tsx,components/swipeui/ui/use-checkbox.tsand 13 shared helpers. - Installs react-native-gesture-handler, react-native-reanimated, react-native-svg, uniwind, clsx, tailwind-merge, react-native-worklets, expo-haptics, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Checkbox, CheckboxGroup } from '@/components/swipeui/ui/checkbox';
<Checkbox label="Email updates" description="A short summary every Monday" />;Examples
A group with a tri-state parent. The parent is ticked when every option is, mixed when some are, and tapping it ticks or clears them all:
<CheckboxGroup
label="Back up"
parentLabel="All folders"
options={[
{ value: 'photos', label: 'Photos', description: '2.4 GB' },
{ value: 'videos', label: 'Videos', description: '11.8 GB' },
]}
/>A to-do list with round boxes and struck-through labels:
<CheckboxGroup options={tasks} shape="circle" strikeOnCheck />At most three, with the reason spoken when a fourth is refused:
<CheckboxGroup label="Interests" options={topics} max={3} />API reference
CheckboxProps
| Prop | Type | Default | Description |
|---|---|---|---|
layout? | | — | Optional layout transition for composed controls; derive its values from useMotion. |
motion? | | | The app's press character, or a local override. Check, fill and press motion (toggle and press roles). |
className? | | | Classes merged after the base target and radius roles. |
checked? | | — | Whether it's ticked (controlled). |
defaultChecked? | | | Whether it starts ticked (uncontrolled). |
onCheckedChange? | | — | Reports a tap's new state; from the mixed state a tap asks for |
value? | | — | 1.x name for |
defaultValue? | | — | 1.x name for |
onValueChange? | | — | 1.x name for |
indeterminate? | | | The mixed state: a dash instead of a check, spoken as mixed. |
label? | | — | Visible label, and the spoken name. |
description? | | — | A second line under the label, also the spoken hint. |
children? | | — | Rich label content in place of |
shape? | | |
|
size? | | | Box size: |
strikeOnCheck? | | | Strike the label through and mute it while ticked, for to-dos. |
invalid? | | | Draws the box in the error colour (a required consent, say). |
accessibilityRole? | | | Radio look and semantics, for 1.x lists built on Checkbox. |
haptics? | | | Haptics: a switch, or per part ( |
style? | | — | Row style. |
labelClassName? | | — | Classes on the label text. |
CheckboxGroup's props are in the group settings table below. Group options are SelectionOptions from selection-core: value, label, description, disabled and disabledReason.
Composition and behavior
- The box and its label are one 44pt checkbox. Ticking fills the box and draws the check on; the mixed state morphs it into a dash, and a tap from mixed asks for ticked. Presses squeeze the box, not the row.
- The box sits on the label's first line at every text size, however far the label wraps. Square corners are a small share of the preset's control radius, so the box stays a box on pill presets.
- ★ In a group, hold a row and drag down the column: each row the finger reaches ticks (or unticks, if the first row was ticked) once, with a tick each. Disabled rows are skipped, and every row can still be tapped.
- max refuses an extra tick: the row shakes, a warning haptic plays and "You can choose up to n" is announced once.
- 1.x:
value,defaultValueandonValueChangestill work besidechecked,defaultCheckedandonCheckedChange;accessibilityRole="radio"draws a dot in a circle.
Checkbox settings
| Prop | Does | Default |
|---|---|---|
| checked / defaultChecked | Ticked (controlled or not); 1.x value works too | false |
| indeterminate | The mixed dash, spoken as mixed | false |
| label / description | Name and a second line (the hint) | none |
| shape | square (small preset corners) or circle | square |
| size | Box sm 18, md 20, lg 24pt | md |
| strikeOnCheck | Strike ticked labels through | false |
| invalid | Error-coloured box | false |
| disabled | No ticking | false |
| haptics | All, or { toggle } | on |
| motion | A local motion feel or override | the app's feel |
Checkbox group settings
| Prop | Does | Default |
|---|---|---|
| options / value / defaultValue | Options and the ticked values | [] |
| label | The group heading and name | none |
| parentLabel / indent | A tri-state parent (true for "Select all"); indent the rows | none, true |
| max | The most that can be ticked | unlimited |
| paintSelect / holdDelay | ★ Hold and drag down to tick a run (ms to hold) | true, 300 |
| shape / size / strikeOnCheck | Passed to every row | square, md, false |
| disabled | No ticking or painting | false |
| haptics | All, or { toggle, select, limit } | on |
| messages | "Select all", the limit and "Unavailable" | English |
Behavior and gestures
- Tap the box or its label to tick it: the box fills and the check draws itself on, with a light tick.
- Tap again to untick. From the mixed state (a dash), a tap asks for ticked, and the dash morphs into the check.
- Presses squeeze the box, not the row.
- In a CheckboxGroup with `parentLabel`, the parent is ticked when every enabled option is, mixed when some are; tapping it ticks them all (up to `max`) or clears them.
- ★ In a group, hold a row (300 ms) and drag down the column: each row the finger reaches ticks (or unticks, if the first row was ticked), once, with a tick each (`paintSelect`). Disabled rows are skipped.
- With `max`, an extra tap is refused: the row shakes once, a warning haptic plays and "You can choose up to n" is announced.
- With `strikeOnCheck`, ticked labels are struck through and muted.
- In controlled mode your app can reject a change and the box stays as it was.
Accessibility
- Each box and its label are one 44pt checkbox with one name, reporting checked, unchecked or mixed; `description` (or a disabled option's reason) is the hint.
- Inside a Field, a lone checkbox takes the field's label, disabled and invalid state.
- Paint always has a tap path: every row can be tapped on its own. Limits are announced once per refusal.
- Rich `children` need an `accessibilityLabel`.
Motion
- Uses the
toggleandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The fill grows in and the check draws on (or morphs to and from the dash) on the toggle role; the box squeezes on the press role.
- A refused tap shakes the row once.
- Reduce Motion: the fill and mark fade in without growing or drawing; haptics stay.
Performance
- Marks are SVG strokes animated on the UI thread; paint compares rows on the UI thread, so a fast drag gives one call per row.
Notes for AI
- Use `checked`/`onCheckedChange` (1.x `value`/`onValueChange` still work) or `defaultChecked`; set `indeterminate` for a hand-made select-all, or use CheckboxGroup's `parentLabel`.
- CheckboxGroup options are `SelectionOption`s from selection-core (`description`, `disabled`, `disabledReason`).
- `accessibilityRole="radio"` draws a dot in a circle, for 1.x lists built on Checkbox.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.