@aargon-ui/checkbox
v1.0.0-beta.1
Published
Animated checkbox component for React Native
Maintainers
Readme
Aargon Checkbox
A highly customizable, animated checkbox component for React Native with smooth animations and modern design.
Features
- 🎨 Multiple Variants - Default, filled, and outlined styles
- 📏 Size Options - Small, medium, and large sizes
- ⚡ Smooth Animations - Spring, timing, and bounce animations
- 🎯 Accessibility - Full accessibility support with proper ARIA attributes
- 🎨 Customizable Themes - Complete theming system with colors and styling
- 🔧 Flexible API - Easy to use with comprehensive props
- 📱 React Native - Built specifically for React Native with Reanimated
- 🌟 TypeScript - Full TypeScript support with comprehensive types
Installation
npm install @aargon-ui/checkbox
# or
yarn add @aargon-ui/checkboxPeer Dependencies
Make sure you have the required peer dependencies installed:
npm install react react-native react-native-reanimatedQuick Start
import React, { useState } from 'react';
import { View, Text } from 'react-native';
import { AnimatedCheckbox } from '@aargon-ui/checkbox';
export default function App() {
const [checked, setChecked] = useState(false);
return (
<View>
<AnimatedCheckbox checked={checked} onPress={() => setChecked(!checked)}>
<Text>Check me</Text>
</AnimatedCheckbox>
</View>
);
}Basic Usage
Simple Checkbox
const [checked, setChecked] = useState(false);
<AnimatedCheckbox checked={checked} onPress={() => setChecked(!checked)}>
<Text>Check me</Text>
</AnimatedCheckbox>;Without Label
<AnimatedCheckbox checked={checked} onPress={() => setChecked(!checked)} />Indeterminate State
<AnimatedCheckbox checked={checked} indeterminate={true} onPress={() => setChecked(!checked)}>
<Text>Indeterminate</Text>
</AnimatedCheckbox>Variants
Default Variant
<AnimatedCheckbox variant="default">Default</AnimatedCheckbox>Filled Variant
<AnimatedCheckbox variant="filled">Filled</AnimatedCheckbox>Outlined Variant
<AnimatedCheckbox variant="outlined">Outlined</AnimatedCheckbox>Sizes
<AnimatedCheckbox size="sm">Small</AnimatedCheckbox>
<AnimatedCheckbox size="md">Medium</AnimatedCheckbox>
<AnimatedCheckbox size="lg">Large</AnimatedCheckbox>Animation Types
Spring Animation (Default)
<AnimatedCheckbox animationType="spring">Spring</AnimatedCheckbox>Timing Animation
<AnimatedCheckbox animationType="timing" duration={500}>
Timing
</AnimatedCheckbox>Bounce Animation
<AnimatedCheckbox animationType="bounce">Bounce</AnimatedCheckbox>Custom Styling
Custom Theme
const customTheme = {
colors: {
background: '#3B82F6',
border: '#1D4ED8',
checkmark: '#FFFFFF',
},
borderRadius: 4,
};
<AnimatedCheckbox theme={customTheme}>Custom Theme</AnimatedCheckbox>;With Shadow
<AnimatedCheckbox shadow={true}>With Shadow</AnimatedCheckbox>Advanced Usage
Disabled State
<AnimatedCheckbox disabled={true}>Disabled</AnimatedCheckbox>Custom Checkmark
<AnimatedCheckbox customCheckmark={<Text>✓</Text>} checked={checked} onPress={() => setChecked(!checked)}>
Custom Checkmark
</AnimatedCheckbox>Checkbox Group
const [values, setValues] = useState(['option1']);
<View>
<AnimatedCheckbox
checked={values.includes('option1')}
onPress={() => {
if (values.includes('option1')) {
setValues(values.filter(v => v !== 'option1'));
} else {
setValues([...values, 'option1']);
}
}}>
Option 1
</AnimatedCheckbox>
<AnimatedCheckbox
checked={values.includes('option2')}
onPress={() => {
if (values.includes('option2')) {
setValues(values.filter(v => v !== 'option2'));
} else {
setValues([...values, 'option2']);
}
}}>
Option 2
</AnimatedCheckbox>
</View>;API Reference
Props
| Prop | Type | Default | Description |
| ----------------- | ------------------------------------- | ----------- | ---------------------------------------------- |
| children | React.ReactNode | - | Label content |
| checked | boolean | false | Whether the checkbox is checked |
| onPress | () => void | - | Function called when checkbox is pressed |
| variant | "default" \| "filled" \| "outlined" | "default" | Visual variant |
| size | "sm" \| "md" \| "lg" | "md" | Size of the checkbox |
| animationType | "timing" \| "spring" \| "bounce" | "spring" | Type of animation |
| duration | number | 300 | Animation duration in milliseconds |
| indeterminate | boolean | false | Whether the checkbox is in indeterminate state |
| disabled | boolean | false | Whether the checkbox is disabled |
| customCheckmark | React.ReactNode | - | Custom checkmark element |
| theme | CheckboxTheme | - | Custom theme object |
| shadow | boolean | false | Whether to show shadow effect |
Types
interface CheckboxTheme {
colors: {
background: string;
border: string;
checkmark: string;
shadow: string;
};
borderRadius: number;
fontFamily?: string;
}
type CheckboxVariant = 'default' | 'filled' | 'outlined';
type CheckboxSize = 'sm' | 'md' | 'lg';
type AnimationType = 'timing' | 'spring' | 'bounce';Accessibility
The checkbox component includes full accessibility support:
- ARIA attributes - Proper
role="checkbox"andaria-checkedattributes - Keyboard navigation - Supports keyboard interaction
- Screen reader support - Announces state changes to screen readers
- Focus management - Proper focus handling for keyboard users
Requirements
- React Native 0.81.0+
- React 19.0.0+
- react-native-reanimated 3.0.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you have any questions or need help, please:
- Check the documentation
- Search existing issues
- Create a new issue
Changelog
See CHANGELOG.md for a list of changes and version history.
Made with ❤️ by Aargon
