1.1.0 • Published 4 years ago

react-native-checkbox-selection v1.1.0

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

react-native-checkbox-selection

A customizables ListView that allows you to select multiple and single rows.

Install

Using NPM

npm install react-native-checkbox-selection

Using Yarn

yarn add react-native-checkbox-selection

Example

Single Select at a timeSelect With TitleSelect Without Title
npm.ionpm.ionpm.io

Usage

import React, { Component } from "react";
import { View } from "react-native";
import MultiSelect from "react-native-checkbox-selection";

const fruits = ["Apples", "Oranges", "Pears"];
// --- OR ---
// const fruits = [
//   { label: 'Apples', value: 'appls' },
//   { label: 'Oranges', value: 'orngs' },
//   { label: 'Pears', value: 'pears' }
// ]

class App extends Component {
  state = { selectedFruits: [] };

  onSelectionsChange = (selectedFruits) => {
    // selectedFruits is array of { label, value }
    this.setState({ selectedFruits });
  };

  render() {
    return (
      <View>
        <MultiSelect
          data={fruits}
          onSelectedItemsChange={onSelectionsChange}
          selectedItems={this.state.selectedFruits}
          enableTitle
          title={"Select Fruits"}
        />
      </View>
    );
  }
}
export default App;

Properties

PropDefaultTypeDescription
data[]arrayAll items available in the list (array of string or { label, value })
selectedItems[]arrayThe currently selected items (array of string or { label, value })
onSelectedItemsChange-funcCallback called when a user selects or de-selects an item, passed (selections)
checkboxSourceimageobjectImage source for the checkbox (unchecked).
selectedCheckboxSourceimageobjectImage source for the checkbox (checked).singlefalseboolMake an signle selection
disableAutoClosefalseboolDisable Automatic Closing funcation
iconDisabledfalseboolDisable caret icon
enableTitlefalseboolenable title for component
iconcaret-downstringchange caret icon
containerStyle{}objectStyle for the container label.
styleTextDropdown{}objectStyle for the dropdown text.

License

© Suraj Sanwal