Skip to content

Checkbox Primitive

A box that is a checked (ticked) indicator when activated.

Installation

Install the component via your command line.

Terminal window
npx expo install @rn-primitives/checkbox

Usage

import * as CheckboxPrimitive from '@rn-primitives/checkbox';
function Example() {
const [checked, setChecked] = React.useState(false);
return (
<CheckboxPrimitive.Root
checked={checked}
onCheckedChange={setChecked}
style={{
height: 16,
width: 16,
borderWidth: 1,
borderColor: 'black',
justifyContent: 'center',
alignItems: 'center',
}}
>
<CheckboxPrimitive.Indicator>
<View style={{ height: 12, width: 12, backgroundColor: 'red' }} />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
);
}

Props

Root

Extends Pressable props

PropTypeNote
checked*boolean
onCheckedChange*(checked: boolean) => void
disabledboolean(optional)

Indicator

Extends View props

PropTypeNote
forceMounttrue | undefined(optional)