Checkbox

An independent on, off or mixed choice.

  • Native host
  • In the first release
import { Checkbox, checkboxPrimitive } from "nitro-ui-sdk/checkbox";
HeroUI Native
Checkbox
Expo UI
Checkbox
  • Checkbox example screen, light appearance
    Light
  • Checkbox example screen, dark appearance
    Dark
On this page

An independent on, off, or mixed choice backed by a native platform control. Use Checkbox for standalone boolean options, multi-select lists, or parent rows that summarize a partial selection ("mixed"). Use Switch for immediate on/off settings and RadioGroup when choices are mutually exclusive.

Anatomy

<Checkbox.Root label="Include archived" hint="Show completed items">
  <Checkbox.Control>
    <Checkbox.Indicator />
  </Checkbox.Control>
  <Checkbox.Label />
  <Checkbox.Hint />
</Checkbox.Root>
Part Description
Checkbox.Root Manages selection state, controller attachment, agent registration, and row layout.
Checkbox.Control Native checkbox host (UIButton with SF Symbols on iOS; MaterialCheckBox on Android).
Checkbox.Indicator Style slot controlling the checkbox glyph size and active tint.
Checkbox.Label Visible label; tapping it toggles the control while staying hidden from duplicate screen-reader focus.
Checkbox.Hint Secondary helper text tied to the control.

Usage

import { Checkbox } from "nitro-ui-sdk/checkbox";

<Checkbox.Root label="Include archived" defaultValue />;

Variants and sizes

variant selects between "binary" (default, refuses "mixed" updates) and "mixed" (supports tri-state "mixed" values). size supports "sm", "md" (default), and "lg", each preserving at least a 44 pt touch target. color accepts semantic intents "accent" (default), "success", and "danger".

<Checkbox.Root label="Small" size="sm" defaultValue />
<Checkbox.Root label="Medium" size="md" defaultValue />
<Checkbox.Root label="Large" size="lg" defaultValue />

<Checkbox.Root label="Accent" color="accent" defaultValue />
<Checkbox.Root label="Approved" color="success" defaultValue />
<Checkbox.Root label="Delete on exit" color="danger" defaultValue />

<Checkbox.Root
  label="Select all projects"
  variant="mixed"
  defaultValue="mixed"
  mixedLabel="Partially selected"
/>

States

Pass disabled to prevent interaction, dim the control and captions with tokens.opacity.disabled, and expose the disabled trait to assistive technology.

<Checkbox.Root label="Locked option" defaultValue disabled />

Controlled

Provide value and onValueChange for controlled state. Calling details.preventDefault() declines a change; leaving value unchanged reconciles the native control back to the committed value.

import { useState } from "react";
import { Checkbox, type CheckboxValue } from "nitro-ui-sdk/checkbox";

const [checked, setChecked] = useState<CheckboxValue>(false);

<Checkbox.Root
  label="Email receipts"
  value={checked}
  onValueChange={(next) => setChecked(next)}
/>;

Props

Checkbox.Root

Prop Type Default Description
label string — Required visible and accessible name.
hint string undefined Optional helper text and accessibility hint.
mixedLabel string undefined Localized accessibility value announced for "mixed" on iOS.
value CheckboxValue undefined Controlled state (boolean | "mixed").
defaultValue CheckboxValue false Initial uncontrolled state.
onValueChange (value: CheckboxValue, details: ActionDetails) => void undefined Called when the value is about to change.
variant "binary" | "mixed" "binary" Allows or refuses "mixed" updates.
size "sm" | "md" | "lg" "md" Visual glyph and tap target size.
color "accent" | "success" | "danger" "accent" Semantic intent color for checked and mixed states.
disabled boolean false Disables user, agent, and controller changes.
styles PartStyles<CheckboxPart, CheckboxVariant, CheckboxSize, CheckboxState> undefined Per-part style overrides.
api Controller<CheckboxActions> undefined Imperative controller created with checkboxPrimitive.createApi().
agentId string undefined Stable agent identity when rendered in recyclable rows.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the root container.
children ReactNode Default anatomy Custom part composition.

Checkbox.Control, Checkbox.Indicator, Checkbox.Label, Checkbox.Hint

Prop Type Default Description
part CheckboxPart Matching part name Overrides the style slot resolved from styles.
children ReactNode / string From root props Optional custom Checkbox.Indicator (on Control) or text override (on Label/Hint).

Controller API

import { Checkbox, checkboxPrimitive } from "nitro-ui-sdk/checkbox";

const api = checkboxPrimitive.createApi();
<Checkbox.Root label="Include archived" api={api} />;
api.current?.toggle();
Action Signature Result
toggle (source?: ActionSource) => ChangeStatus Toggles to true from false/"mixed", or false from true.
setChecked (checked: CheckboxValue, source?: ActionSource) => ChangeStatus Sets an explicit value; refuses "mixed" when variant="binary".

Styles

Style resolvers receive { tokens, variant, size, state } where state is { disabled: boolean; checked: CheckboxValue; color: CheckboxColor }.

<Checkbox.Root
  label="Custom indicator"
  defaultValue
  styles={{
    indicator: ({ tokens }) => ({ text: { color: tokens.colors.success, fontSize: 26 } }),
  }}
/>

Accessibility

Checkbox.Control owns the native accessibility element with the toggleButton trait on iOS 17+ (or button + selected on iOS 16), accessibilityLabel, accessibilityHint, and "0" / "1" / mixedLabel values. Checkbox.Label and Checkbox.Hint stay hidden from assistive focus so VoiceOver and TalkBack announce one control per row. Touch toggles trigger selectionChanged() haptics; agent and API actions never vibrate.

Agent API

Action Arguments Notes
toggle none Toggles the checkbox and settles controlled updates.
setChecked boolean | "mixed" Sets an explicit state; binary checkboxes refuse "mixed".

Platform notes

iOS Android
Implementation UIButton with SF Symbols (square, checkmark.square.fill, minus.square.fill). MaterialCheckBox with tri-state support and selectionHint delegate.
Verification Unit, type, iOS harness, and simulator screenshot verified. Written to compile; not built locally (no Android NDK on this machine).