suiss/uim · React Native Component

Checkbox

A small box that toggles an option on or off, with an indeterminate state.

Checkbox is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Checkbox on iOS in light mode

Checkbox is a Pressable with the checkbox role that shows a check icon when checked and a minus icon when indeterminate. It has an enlarged hit area around the box so it is easy to tap.

Use it for options that can be combined, such as terms acceptance or multi-select lists. For a single on/off setting that applies right away, use Switch.

Installation

$ pnpm dlx @esuiss/uim@latest add checkbox

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text, and the primitives components/primitives/checkbox.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/checkbox.tsx:

uniwind/components/ui/checkbox.tsx
import { cn } from "cn"
import { CheckIcon, MinusIcon } from "phosphor-react-native"
import * as CheckboxPrimitive from "@/components/primitives/checkbox"
import { resolveClassName } from "@/components/primitives/use-render"
import { Icon } from "@/components/ui/icon"

const HIT_SLOP = { top: 8, bottom: 8, left: 12, right: 12 }

function checkboxClassName(
  state: CheckboxPrimitive.RootState,
  invalid: boolean | undefined
) {
  const checked = state.checked || state.indeterminate
  return cn(
    "size-4 shrink-0 items-center justify-center rounded-[4px] border",
    checked
  1. Update the import paths to match your project.

Usage

import { Checkbox } from "@/components/ui/checkbox"
<CheckboxDemo />

Use checked with onCheckedChange for controlled state, or defaultChecked for uncontrolled. Set indeterminate for a parent checkbox whose children are partly selected.

Pair the checkbox with a Label: give the label a nativeID and the checkbox a matching accessibilityLabelledBy, and toggle the value from the label's onPress. Set invalid to show a danger border.

Examples

Checked

Starts checked.

iOS
Checkbox (checked) on iOS in light mode

With label

Linked to a Label that also toggles it.

iOS
Checkbox (with label) on iOS in light mode

With description

A label with a supporting description.

iOS
Checkbox (with description) on iOS in light mode

Disabled

Disabled checkboxes in both states.

iOS
Checkbox (disabled) on iOS in light mode

Indeterminate

A select-all checkbox in the indeterminate state.

iOS
Checkbox (indeterminate) on iOS in light mode

Invalid

A required checkbox with the invalid border.

iOS
Checkbox (invalid) on iOS in light mode

API Reference

Checkbox

ExtendsReact.ComponentProps<typeof CheckboxPrimitive.Root>
PropType
About
Extra classes for the check icon.
Type
string
Default
—
About
Shows a danger-colored border.
Type
boolean
Default
—

Accessibility

  • Has the checkbox role with checked (or mixed when indeterminate) and disabled state.
  • Link it to a visible label with accessibilityLabelledBy, or give it an accessibilityLabel.

Notes

  • Uses bg-accent when checked and bg-surface with a translucent border when unchecked; in dark mode the unchecked box is filled instead of outlined.
  • Light and dark follow the system appearance.