2.0.0 • Published 6 years ago

@pranjal-jain/react-native-chooser v2.0.0

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

React Native Chooser

npm npm Travis Commitizen friendly

Simple yet fully customizable select menu for React Native.

  • Simple: Alot of optional inputs makes it easier to use as you only need to pass inn data for a simple version.
  • Customizable: All elements can be changed to you what you need. Custom components can be added.
  • Standards: Everything is after React`s latest standards.
  • iOS and Android: Supports both platforms out of the box.

PLEASE NOTE: BREAKING CHANGES IN V2.

Version 1 documentation here

Migration from v1 to v2 here

Installation

npm i react-native-chooser --save

or

yarn add react-native-chooser

Usage

import React, { Component } from 'react';
import {Select, Option} from "react-native-chooser";

import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

export default class AwesomeProject extends Component {

  onSelect(data) {
    alert(data);
  }

  render() {
    return (
      <View style={styles.container}>
        <Select
            onSelect = {this.onSelect.bind(this)}
            defaultText  = "Select Me Please"
            style = {{borderWidth : 1, borderColor : "green"}}
            textStyle = {{}}
            backdropStyle  = {{backgroundColor : "#d3d5d6"}}
            optionListStyle = {{backgroundColor : "#F5FCFF"}}
          >
          <Option value = {{name : "azhar"}}>Azhar</Option>
          <Option value = "johnceena">Johnceena</Option>
          <Option value = "undertaker">Undertaker</Option>
          <Option value = "Daniel">Daniel</Option>
          <Option value = "Roman">Roman</Option>
          <Option value = "Stonecold">Stonecold</Option>
          <Option value = "Rock">Rock</Option>
          <Option value = "Sheild">Sheild</Option>
          <Option value = "Orton">Orton</Option>

        </Select>
      </View>
    );
  }
}

Props

Props for Select

Prop NameData TypeDefault ValuesDescription
onSelectfunctionnullfunction that executes on selection of an option
defaultTextstringClick To SelectText to show as default text
styleobjectnullTo style the select box.
backdropStyleobjectnullTo style the overlay
textStyleobjectnullTo style the text shown in the box
optionListStyleobjectnullTo style the selection box
transparentbooleanfalseTo set the transparent prop on Modal
animationTypestring"none"To set the animationType prop on Modal
indicatorstring"none", "up" or "down""none"To enable an indicator arrow
indicatorColorstring"black"The color of the indicator arrow
indicatorSizenumber10The size of the indicator arrow
indicatorStyleobjectnullTo style the indicator arrow
selectedstringnullGive it same value as you give to Option
selectedStyleobjectnullApply styles to the selected Option

Functions for Select

Function NameDescription
setSelectedText(text)Set default text in the select option, often used to reset text.

Props for Option

Prop NameData TypeDefault ValuesDescription
styleobjectnullTo style each option
styleTextobjectnullTo style the text shown in the option

Demo

IOS and Android:

Contributions

Your contributions and suggestions are heartily♡ welcome. (✿◠‿◠)