Checkbox

Forms

An animated checkbox with a label, indeterminate state, and spring-driven check mark animation.

GitHub

Installation

bash
1
npx native-mate add checkbox

Examples

#FAFAFA
Radius100%

Usage

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
import { Checkbox } from '~/components/ui/checkbox'
import { useState } from 'react'

const [accepted, setAccepted] = useState(false)

<Checkbox
  label="I agree to the terms and conditions"
  checked={accepted}
  onCheckedChange={setAccepted}
/>

// Indeterminate (e.g. select-all row)
<Checkbox label="Select all" indeterminate checked={false} onCheckedChange={handleSelectAll} />

Props

PropTypeDefaultDescription
checkedbooleanfalseWhether the checkbox is checked.
onCheckedChange(checked: boolean) => voidCalled when the user toggles the checkbox.
labelstringText label rendered beside the checkbox.
indeterminatebooleanfalseShows a dash instead of a tick — useful for "select all" states.
disabledbooleanfalsePrevents interaction and reduces opacity.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { useState } from 'react'
import { Checkbox } from '~/components/ui/checkbox'
import { View } from 'react-native'

export function CheckboxExample() {
  const [items, setItems] = useState([
    { id: 1, label: 'Milk', checked: false },
    { id: 2, label: 'Eggs', checked: true },
    { id: 3, label: 'Bread', checked: false },
  ])

  const toggle = (id: number) =>
    setItems(prev => prev.map(i => i.id === id ? { ...i, checked: !i.checked } : i))

  return (
    <View style={{ gap: 12, padding: 16 }}>
      {items.map(item => (
        <Checkbox key={item.id} label={item.label} checked={item.checked} onCheckedChange={() => toggle(item.id)} />
      ))}
    </View>
  )
}