0.0.6 • Published 1 year ago

@chainsoft/react-native-checkbox v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@chainsoft/react-native-checkbox

PRs Welcome NPM version License MIT npm

Checkbox component for react native, it works on iOS and Android.

Content

Installation

  • Run npm i @chainsoft/react-native-checkbox --save or yarn add @chainsoft/react-native-checkbox

Getting started

Add @chainsoft/react-native-checkbox to your project.

import CheckBox from '@chainsoft/react-native-checkbox'

Inside your component's render method, use CheckBox:

<CheckBox
  style={{ flex: 1, padding: 10 }}
  onClick={() => {
    this.setState({
      isChecked: !this.state.isChecked,
    });
  }}
  isChecked={this.state.isChecked}
  text={"Check Box"}
/>

Then you can use it like this:

Basic usage

<CheckBox
  style={{ flex: 1, padding: 10 }}
  onClick={() => {
    this.setState({
      isChecked: !this.state.isChecked,
    });
  }}
  isChecked={this.state.isChecked}
  text={"Check Box"}
/>

Custom CheckBox

renderCheckBox(data) {
    var text = data.name;
    return (
        <CheckBox
            onClick={()=>{
                 this.setState({
                     isChecked:!this.state.isChecked
                 })
               }}
            text={text}
            isChecked={this.state.isChecked}
            checkedImage={<Image source={require('../../page/my/img/ic_check_box.png')} style={this.props.theme.styles.tabBarSelectedIcon}/>}
            unCheckedImage={<Image source={require('../../page/my/img/ic_check_box_outline_blank.png')} style={this.props.theme.styles.tabBarSelectedIcon}/>}
        />);
}

API

PropsTypeOptionalDefaultDescription
styleView.propTypes.styletrueCustom style checkbox
textPropTypes.stringtrueCustom Text
textStyleText.propTypes.styletrueCustom Text style
textAlignPropTypes.stringtrue'left'text Align left or right (value: 'left', 'right')
checkedImagePropTypes.elementtrueDefault imageCustom checked Image
unCheckedImagePropTypes.elementtrueDefault imageCustom unchecked Image
isCheckedPropTypes.boolfalsefalsecheckbox checked state
onClickPropTypes.func.isRequiredfalsecallback function
disabledPropTypes.booltruefalseDisable the checkbox button
checkBoxColorPropTypes.stringtrueTint color of the checkbox image (this props is for both checked and unchecked state)
checkedColorPropTypes.stringtrueTint color of the checked state checkbox image (this prop will override value of checkBoxColor for checked state)
unCheckedColorPropTypes.stringtrueTint color of the unchecked state checkbox image (this prop will override value of checkBoxColor for unchecked state)

Contribution

Issues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.

Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.

MIT Licensed

To support this project, you can make a donation to its current maintainer: Donate Donate

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago