Skip to content
Docs
Components
Inputs
Checkbox

Checkbox

Component to render a checkbox input.

Import

import { Checkbox, CheckboxGroup } from 'react-native-ficus-ui';

Usage

Simple checkbox

EDITABLE EXAMPLE
<VStack>
  <Checkbox value={1} prefix={<Text flex={1}>Option 1</Text>} />
  <Checkbox value={2} prefix={<Text flex={1}>Option 2</Text>} />
  <Checkbox
    value={3}
    prefix={<Text flex={1}>Option 3</Text>}
    colorScheme="red"
  />
  <Checkbox
    value={4}
    prefix={<Text flex={1}>Option 4</Text>}
    colorScheme="pink"
  />
  <Checkbox value={5} prefix={<Text flex={1}>Option 5</Text>} isLoading />
</VStack>

Checkbox sizes

EDITABLE EXAMPLE
<VStack>
  <Checkbox value={1}>Option 1</Checkbox>
  <Checkbox value={2} size="lg">
    Option 2
  </Checkbox>
  <Checkbox value={3} size="lg" isLoading>
    Option 3
  </Checkbox>
</VStack>

Checkbox disabled

EDITABLE EXAMPLE
<Checkbox value={1} isDisabled>
  Option 1
</Checkbox>

Checkbox group

EDITABLE EXAMPLE
<CheckboxGroup colorScheme="green">
  <Checkbox value={1}>Option 1</Checkbox>
  <Checkbox value={2}>Option 2</Checkbox>
</CheckboxGroup>

Custom render

EDITABLE EXAMPLE
<CheckboxGroup flexDirection="row">
  {['Option 1', 'Option 2', 'Option 3'].map((item) => (
    <Checkbox value={item}>
      {({ isChecked }) => (
        <Badge
          variant={isChecked ? 'solid' : 'subtle'}
          colorScheme="pink"
          fontSize="lg"
          px="md"
          py="md"
          borderRadius="full"
          mx="sm"
        >
          {item}
        </Badge>
      )}
    </Checkbox>
  ))}
</CheckboxGroup>

Props

Checkbox props

Extends every Box props.

colorScheme

The colorScheme property, will define checkbox color.

TypeRequiredDefault
stringNoblue

defaultChecked

Boolean to indicate if checkbox should be checked by default.

TypeRequiredDefault
booleanNofalse

isChecked

Boolean to indicate if checkbox is checked.

TypeRequiredDefault
booleanNofalse

isDisabled

Boolean to indicate if checkbox is disabled.

TypeRequiredDefault
booleanNofalse

isLoading

Boolean to indicate if checkbox should display a loader/spinner.

TypeRequiredDefault
booleanNofalse

onChecked

Function called when checked status changes on checkbox.

TypeRequired
(newValue: boolean) => voidNo

icon

Custom icon component to replace default checkbox icon.

TypeRequired
React.ReactNodeNo

iconColor

Custom icon color.

TypeRequired
stringNo

size

Size of checkbox.

TypeRequired
number 'sm' 'lg'No

Checkbox.Group props

onChange

Function called when checked value changes.

TypeRequired
(value: any) => voidNo

value

Value for the checkbox group.

TypeRequired
anyNo

defaultValue

Default value for the checkbox group.

TypeRequired
anyNo

colorScheme

The colorScheme property, will define group checkboxs color.

TypeRequiredDefault
stringNoblue