Giter VIP home page Giter VIP logo

react-native-checkbox-reanimated's Introduction

react-native-checkbox-reanimated

Animated checkbox built with Reanimated v2. This component has been created for the React Native tutorial here.

demo

Prerequisites

Installation

npm install react-native-checkbox-reanimated
npm install react-native-reanimated react-native-svg

When you're done installing react-native-reanimated don't forget to add the plugin to your babel.config.js file. Like so:

module.exports = {
  presets: [
    ...
  ],
  plugins: [
    ...
    'react-native-reanimated/plugin',
  ],
};

make sure the react-native-reanimated/plugin is added last.

Please make sure that you give the React Native Reanimated Documentation a read.

Please take note that in most cases while using this package with expo, the version of expo that you have installed will not be compatible with the latest version of the react-native-reanimated package and the react-native-svg package so if you get an error like so:

Some dependencies are incompatible with the installed expo package version:
  - react-native-reanimated - expected version: ~2.9.1 - actual version installed: 2.10.0
  - react-native-svg - expected version: 12.3.0 - actual version installed: 13.1.0
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name ...]

make sure you run the recommended expo doctor --fix-dependencies command to fix it and clear any errors you might have while using this package.

Usage

import React, { useState } from 'react'
import { StyleSheet, View, Pressable } from 'react-native'
import AnimatedCheckbox from 'react-native-checkbox-reanimated'

export default function App() {
  const [checked, setChecked] = useState<boolean>(false)

  const handleCheckboxPress = () => {
    setChecked(prev => {
      return !prev
    })
  }

  return (
    <View style={styles.container}>
      <Pressable onPress={handleCheckboxPress} style={styles.checkbox}>
        <AnimatedCheckbox
          checked={checked}
          highlightColor="#4444ff"
          checkmarkColor="#ffffff"
          boxOutlineColor="#4444ff"
        />
      </Pressable>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
  },
  checkbox: {
    width: 64,
    height: 64
  }
})

License

MIT


Looking for a Markdown note-taking app? Check out my app called Inkdrop:

Inkdrop

react-native-checkbox-reanimated's People

Contributors

craftzdog avatar denisfanteria avatar michaelessiet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.