Tac UIv1.1.2

Checkbox

A toggleable input for boolean choices, supporting checked, unchecked, and indeterminate states.

Import

tsx
import { Checkbox } from '@tac-ui/native';

Playground

Interactively configure the Checkbox props below.

tsx
<Checkbox label="Accept terms and conditions" />

Default

Uncontrolled checkbox using defaultChecked. The component manages its own state internally.

tsx
<Checkbox label="Accept terms and conditions" />
<Checkbox label="Pre-checked" defaultChecked />

Indeterminate

The indeterminate state represents a partially-selected state, useful for parent checkboxes in a hierarchical selection.

tsx
<Checkbox label="Select all (partial)" indeterminate />

Disabled

Disabled checkboxes are non-interactive and visually dimmed, preserving their current state.

tsx
<Checkbox label="Disabled unchecked" disabled />
<Checkbox label="Disabled checked" disabled defaultChecked />

Controlled

Pass checked and onChange to control the checkbox state from a parent component.

tsx
import { useState } from 'react';

function ControlledExample() {
  const [checked, setChecked] = useState(false);

  return (
    <Checkbox
      label={checked ? 'Checked' : 'Unchecked'}
      checked={checked}
      onChange={setChecked}
    />
  );
}

All States

Overview of all four visual states: default, checked, indeterminate, and disabled.

tsx
<Checkbox label="Default" />
<Checkbox label="Checked" defaultChecked />
<Checkbox label="Indeterminate" indeterminate />
<Checkbox label="Disabled" disabled />

API Reference

PropTypeDefaultDescription
labelstring-Label text displayed next to the checkbox.
checkedboolean-Controlled checked state. Use with onChange for a controlled input.
defaultCheckedbooleanfalseInitial checked state for uncontrolled usage.
indeterminatebooleanfalseRenders a dash icon representing a partially-selected state.
filledbooleanfalseAdds a tinted background to the checkbox label area.
disabledbooleanfalseDisables the checkbox, making it non-interactive and visually dimmed.
onChange(checked: boolean) => void-Callback fired when the checked state changes.
styleViewStyle-Additional React Native style applied to the wrapper container.