Skip to main content

Checkbox

A multi-select group, controlled via values. Built from Checkbox.Root and Checkbox.Item (which internally composes Checkbox.Indicator and Checkbox.Label).

Basic usage

React Native
TypeScript
Expo
function CheckboxExample() {
const [values, setValues] = useState<string[]>(['react-native']);

return (
<Checkbox.Root values={values} onChange={setValues}>
<Checkbox.Item value="react-native" label="React Native" />
<Checkbox.Item value="typescript" label="TypeScript" />
<Checkbox.Item value="expo" label="Expo" />
</Checkbox.Root>
);
}

Color and disabled state

color on Checkbox.Root sets the selected fill/border token for every item. Set isDisabled on the root to disable the whole group, or on an individual Checkbox.Item to disable just that item.

Enabled
Disabled item
<Checkbox.Root values={values} onChange={setValues} color="success">
<Checkbox.Item value="a" label="Enabled" />
<Checkbox.Item value="b" label="Disabled item" isDisabled />
</Checkbox.Root>

Custom icon

By default a selected checkbox shows a plain ✓ glyph. Pass icon on Checkbox.Root to use a real icon instead: any component matching TVajraIconComponent, applied to every item.

React Native
import { CheckIcon } from '@devraj-labs/vajra-ui-icons';

<Checkbox.Root values={values} onChange={setValues} icon={CheckIcon}>
<Checkbox.Item value="a" label="React Native" />
</Checkbox.Root>

Props

Checkbox.Root Props

PropTypeDefaultDescription
valuesstring[]Required. Currently selected item values. Controlled.
onChange(values: string[]) => voidRequired. Called with the next selected values when an item is pressed.
colorTVajraColors'primary'Selected fill/border color token, applied to every item's indicator.
isDisabledbooleanfalseDisables all items unless individually overridden.
iconTVajraIconComponentIcon shown in a selected checkbox. Defaults to a plain ✓ glyph.
childrenReactNodeRequired. Checkbox.Item elements.

Checkbox.Item Props

PropTypeDefaultDescription
valuestringRequired. Unique identifier matched against values.
labelstringOptional label text rendered next to the indicator.
isDisabledbooleanOverrides the root's isDisabled for this item.

Checkbox.Indicator Props

PropTypeDefaultDescription
isSelectedbooleanRequired. Whether to render the filled/checked state.
isDisabledbooleanRequired. Dims the indicator.
colorTVajraColors'primary'Fill/border color token when selected.
iconTVajraIconComponentIcon shown when selected. Defaults to a plain ✓ glyph.

Checkbox.Label Props

PropTypeDefaultDescription
labelstringRequired. Text to display.
isDisabledbooleanRequired. Dims the label.