Introduction
Components
- Accordion
- Action Sheet
- Alert
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- AvoidKeyboard
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Charts
Installation
pnpm dlx bna-ui add checkbox
Usage
import { Checkbox } from '@/components/ui/checkbox';
const [checked, setChecked] = useState(false);
<Checkbox
checked={checked}
onCheckedChange={setChecked}
label='Accept terms and conditions'
/>;
Examples
Default
Different States
Without Label
With Error State
Custom Styling
Checkbox Group
API Reference
Checkbox
A checkbox component that allows users to select or deselect an option.
Prop | Type | Default | Description |
---|---|---|---|
checked | boolean | - | Whether the checkbox is checked. |
onCheckedChange | (checked: boolean) => void | - | Callback function called when the checked state changes. |
label | string | - | Optional label text to display next to the checkbox. |
error | string | - | Error message to display (affects styling). |
disabled | boolean | false | Whether the checkbox is disabled. |
labelStyle | TextStyle | - | Additional styles to apply to the label text. |
Accessibility
The Checkbox component is built with accessibility in mind:
- Uses TouchableOpacity for proper touch handling
- Supports disabled state with reduced opacity
- Label text is properly associated with the checkbox
- Provides visual feedback for checked/unchecked states
- Uses semantic color theming for different states
- Supports custom styling while maintaining accessibility
Theming
The component uses the following theme colors:
primary
: Color for checked state border and backgroundprimaryForeground
: Color for the check iconborder
: Color for unchecked state borderred
: Color for error state styling
These colors are automatically resolved using the useThemeColor
hook to support light and dark themes.