Tally UI
UI

Checkbox

A styled checkbox control with a checkmark indicator, built on the Checkbox primitive.

Import

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

Usage

<Checkbox checked={checked} onCheckedChange={setChecked} />

Checkbox is a pre-styled wrapper around Checkbox.Root and Checkbox.Indicator from @tallyui/primitives. It renders a checkmark character when checked. See the Checkbox primitive for behavior and accessibility details.

Default Styling

StateClasses
Baseh-4 w-4 shrink-0 rounded-sm border border-primary
Checkedbg-primary
Disabledopacity-50 web:cursor-not-allowed
Focus (web)ring-2 ring-ring ring-offset-2 ring-offset-background
Indicatorflex items-center justify-center text-current
Checkmarktext-xs text-primary-foreground

Props

PropTypeDefaultDescription
checkedboolean---Controlled checked state
defaultCheckedbooleanfalseInitial checked state (uncontrolled)
onCheckedChange(checked: boolean) => void---Called when the checked state changes
disabledbooleanfalsePrevents interaction and applies opacity-50
classNamestring---Additional NativeWind classes merged via cn()

Plus all React Native PressableProps.

Examples

Controlled with label

import { useState } from 'react';
import { View } from 'react-native';
import { Checkbox, Label, Text } from '@tallyui/components';

function TermsCheckbox() {
  const [accepted, setAccepted] = useState(false);

  return (
    <View className="flex-row items-center gap-2">
      <Checkbox
        checked={accepted}
        onCheckedChange={setAccepted}
        nativeID="terms"
      />
      <Label nativeID="terms">
        <Text>Accept terms and conditions</Text>
      </Label>
    </View>
  );
}

Disabled

<Checkbox disabled />
<Checkbox disabled checked />

Custom size

<Checkbox className="h-6 w-6" />

On this page