0.1.0 • Published 7 years ago

react-native-checkbox-plus v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

react-native-checkbox-plus

NPM version react-native react node version npm download

Simple customizable react-native checkbox Edit

Getting Started

Installation

npm i react-native-checkbox-plus --save

Basic Usage

import React, { Component } from 'react'
import { AppRegistry, View } from 'react-native'
import Checkbox from 'react-native-checkbox-plus'

class Example extends Component {
  ...
  constructor(props) {
    super(props)
    this.state = {
      isChecked: false,
      isChecked_ShortHand: false
    }
  }
  ...
  render() {
    return (
        <View style={{flex: 1}}>
          /* Normal Case */
          <View style={{flexWrap: 'wrap', flexDirection: 'row'}}>
            <Checkbox 
              isChecked={this.state.isChecked}
              action={() =>  this.setState({ isChecked: !this.state.isChecked }) }
            />
            <View style={{justifyContent:'center'}}>
              <Text>Check It now!</Text>
            </View>
          </View>
          /* ShortHand Case */
          <Checkbox
            useRipple={false}
            isAccessContext
            rightContext={<Text>What !?</Text>}
            isChecked={this.state.isChecked_ShortHand}
            action={() =>  this.setState({ isChecked_ShortHand: !this.state.isChecked_ShortHand })}
          />
        </View>
    )}
}

AppRegistry.registerComponent('Example', () => Example)

Properties


PropsTypeDefaultDescription
isCheckedbool(Required)falsecheckbox status
actionfunc(Required)() => { }use action while press
useRipplebool(Required)trueuse effect while press
sizenumber(Required)falsesize of ripple
checkedCustomIconstring-use custom icon on checked status
unCheckedCustomIconstring-use custom icon on unchecked status
isAccessContextboolfalseaccess to use rightContext
rightContextelementnulluse custom in right context

License

react-native-checkbox-plus is released under the MIT license.