SwipeUI

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 checkbox
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When 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.ts and 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 install so versions match your SDK.

Usage

app/settings.tsx
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

PropTypeDefaultDescription
layout?union—

Optional layout transition for composed controls; derive its values from useMotion.

motion?MotionOverridethe app's feel

The app's press character, or a local override. Check, fill and press motion (toggle and press roles).

className?stringundefined

Classes merged after the base target and radius roles.

checked?boolean—

Whether it's ticked (controlled).

defaultChecked?booleanfalse

Whether it starts ticked (uncontrolled).

onCheckedChange?((checked: boolean) => void)—

Reports a tap's new state; from the mixed state a tap asks for true.

value?boolean—

1.x name for checked.

defaultValue?boolean—

1.x name for defaultChecked.

onValueChange?((checked: boolean) => void)—

1.x name for onCheckedChange.

indeterminate?booleanfalse

The mixed state: a dash instead of a check, spoken as mixed.

label?string—

Visible label, and the spoken name.

description?string—

A second line under the label, also the spoken hint.

children?ReactNode—

Rich label content in place of label (pass accessibilityLabel for the name).

shape?CheckboxShape'square'

square (small preset corners) or circle.

size?CheckboxSize'md'

Box size: sm 18pt, md 20pt, lg 24pt.

strikeOnCheck?booleanfalse

Strike the label through and mute it while ticked, for to-dos.

invalid?booleanfalse

Draws the box in the error colour (a required consent, say).

accessibilityRole?"checkbox" | "radio"'checkbox'

Radio look and semantics, for 1.x lists built on Checkbox.

haptics?boolean | SelectionHapticstrue

Haptics: a switch, or per part (toggle for a tick).

style?StyleProp<ViewStyle>—

Row style.

labelClassName?string—

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, defaultValue and onValueChange still work beside checked, defaultChecked and onCheckedChange; accessibilityRole="radio" draws a dot in a circle.

Checkbox settings

PropDoesDefault
checked / defaultCheckedTicked (controlled or not); 1.x value works toofalse
indeterminateThe mixed dash, spoken as mixedfalse
label / descriptionName and a second line (the hint)none
shapesquare (small preset corners) or circlesquare
sizeBox sm 18, md 20, lg 24ptmd
strikeOnCheckStrike ticked labels throughfalse
invalidError-coloured boxfalse
disabledNo tickingfalse
hapticsAll, or { toggle }on
motionA local motion feel or overridethe app's feel

Checkbox group settings

PropDoesDefault
options / value / defaultValueOptions and the ticked values[]
labelThe group heading and namenone
parentLabel / indentA tri-state parent (true for "Select all"); indent the rowsnone, true
maxThe most that can be tickedunlimited
paintSelect / holdDelay★ Hold and drag down to tick a run (ms to hold)true, 300
shape / size / strikeOnCheckPassed to every rowsquare, md, false
disabledNo ticking or paintingfalse
hapticsAll, 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 toggle and press motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items