1.2.0 • Published 8 years ago

react-native-icon-checkbox v1.2.0

Weekly downloads
10
License
MIT
Repository
github
Last release
8 years ago

react-native-icon-checkbox

react native Checkbox / RadioButton component implement with react-native-vector-icons

use Material Icons

Gif

Installation

  1. need to Install react-native-vector-icons first
  2. npm install react-native-icon-checkbox --save

Usage

import React, {
  View,
  Component,
} from 'react-native';
import CheckBox from 'react-native-icon-checkbox';

export default class Policies extends Component {

  constructor(props) {
    super(props);
    this.state = {
      isChecked: false,
      isRadioSelected: true,
    };
  }

  handlePressCheckedBox = (checked) => {
    this.setState({
      isChecked: checked,
    });
  }

  handleSelectedRadionButton = (checked) => {
    this.setState({
      isRadioSelected: checked,
    });
  }

  render() {
    return (
      <View style={{ flex: 1, padding: 20 }}>
        <CheckBox
          label="Checkbox"
          size={30}
          checked={this.state.isChecked}
          onPress={this.handlePressCheckedBox}
        />
        {/* You can use other Icon */}
        {/* Here is the example of Radio Icon */}
        <CheckBox
          label="RadioButton"
          size={30}
          checked={this.state.isRadioSelected}
          onPress={this.handleSelectedRadionButton}
          uncheckedIconName="radio-button-unchecked"
          checkedIconName="radio-button-checked"
        />
      </View>
    );
  }
}

Properties

PropPropTypeDefault ValueDescription
sizenumber30icon size
checkedboolfalsechecked state
uncheckedIconNamestring'check-box'material icons (need to replace space with '-' )
checkedIconNamestring'check-box-outline-blank'material icons (need to replace space with '-' )
labelstring{fontSize: 16}label of button
labelStyleobjectstyle of label
iconStyleobject{marginLeft: -10}color of the icon
checkedIconStyleobjecticon style when checked
colorstring'#000'icon color
backgroundColorstring'rgba(0,0,0,0)'background color of the button
onPressfuncA function called when the button is pressed.
underlayColorstring'rgba(0,0,0,0)'prop of TouchableHighlight
activeOpacitynumber1prop of TouchableHighlight
borderRadiusnumber5borderRadius of button

Other Props :

TouchableHighlight's Props

https://github.com/oblador/react-native-vector-icons#properties-1

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago