Tally UI
Primitives

Checkbox

A control that toggles between checked and unchecked states.

Import

import { Checkbox } from '@tallyui/primitives';

Usage

<Checkbox.Root checked={checked} onCheckedChange={setChecked}>
  <Checkbox.Indicator>
    {checked && <CheckIcon />}
  </Checkbox.Indicator>
</Checkbox.Root>

Components

Checkbox.Root

The pressable container that manages the checked state.

PropTypeDefaultDescription
checkedbooleanControlled checked state
defaultCheckedbooleanfalseInitial checked state (uncontrolled)
onCheckedChange(checked: boolean) => voidCalled when the checked state changes
disabledbooleanfalsePrevents interaction
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Checkbox.Indicator

Renders inside Root when the checkbox is checked. Use forceMount to always render it (useful for animations).

PropTypeDefaultDescription
forceMounttrueAlways render regardless of checked state
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

Accessibility

  • Role: checkbox
  • ARIA: aria-checked, aria-disabled
  • Toggles on press

Examples

Controlled

function ControlledCheckbox() {
  const [checked, setChecked] = React.useState(false);

  return (
    <Checkbox.Root checked={checked} onCheckedChange={setChecked}>
      <Checkbox.Indicator forceMount>
        {checked ? <CheckIcon /> : null}
      </Checkbox.Indicator>
    </Checkbox.Root>
  );
}

On this page