0.1.3 • Published 5 years ago

react-native-select-awesome v0.1.3

Weekly downloads
83
License
MIT
Repository
github
Last release
5 years ago

React Native Select Awesome - Library for React Native on platform Android and iOS

View on Github 1 View on Github 2 View on Github 3

Table of Content

  1. What is React Native Select Awesome?
  2. Getting Started
  3. Props
  4. Example
  5. License

1. What is React Native Select Awesome?

React Native Select Awesome ingenious and dynamic front-end framework created by TuanTVK to build cross platform Android & iOS mobile apps using ready to use generic components of React Native.

2. Getting Started

Install

npm install react-native-select-awesome --save

# or use yarn

yarn add react-native-select-awesome

Import

import RNSelect from 'react-native-select-awesome';

or

var RNSelect = require('react-native-select-awesome');

3. Props

Follow Style in React Native

PropsDescriptionDefaultPropTypes
datasspecify the options the user can select from[]array isRequired
valuecontrol the current value""string
placeholderchange the text displayed when no option is selectedSelect valuestring
labelcustomize label for select itemlabelstring
widthwidth of input100%string
heightheight of input50number
styleInputstyle customize for input{}object
styleItemstyle customize for item select{}object
stylePickerstyle customize container picker{ height: 250 }object
notFindchange the text displayed when no find valueNot Findstring
styleNotFindstyle customize for text notFind{}object
isDisabledwhether the input is disabledtruebool
selectValuereturn value when you use rightIcon props and select() => { }func
rightIconcustomize component right, it is function return element of you and prop clearValuenullfunc
clearValueclear value of select when you use rightIcon props and selectfunc
customItemcustomize select item use component of you, it is function return prop (item, onPress)nullfunc

4. Example

Ex1: Basic

// At the top of your file
import React, { Component } from 'react';
import { View } from 'react-native';
import RNSelect from 'react-native-select-awesome';

const LANGS = [
  {id: 1, label: 'Java', value: 'java'},
  {id: 2, label: 'JavaScript', value: 'js'},
  {id: 3, label: 'Python', value: 'py'},
  {id: 4, label: 'C', value: 'c'},
  {id: 5, label: 'PHP', value: 'php'},
];

const itemCustom = {color: '#146eff' };

// Later on in your component
export default class RNSelectExample extends Component {
  render() {
    return(
      <View>
        <RNSelect 
          datas={LANGS}
          placeholder="Select lang"
          height={60}
          styleItem={itemCustom}
        />
      </View>
    )
  }
}

Ex2: Custom item

// At the top of your file
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import RNSelect from 'react-native-select-awesome';

const PERSONS = [
  {id: 1, name: 'Alexander', value: 'alexander'},
  {id: 2, name: 'Ethan', value: 'ethan'},
  {id: 3, name: 'Daniel', value: 'daniel'},
  {id: 4, name: 'Matthew', value: 'matthew'},
  {id: 5, name: 'Joseph', value: 'joseph'},
];

// Later on in your component
export default class RNSelectExample2 extends Component {
  render() {
    return(
      <View>
        <RNSelect 
          datas={PERSONS}
          placeholder="Select people"
          label="name"
          notFind="Opp... !"
          styleNotFind={{ textAlign: 'center' }}
          customItem={(item, _selectValue) => {
            return (
              <View style={{marginBottom: 10, backgroundColor: '#f00'}}>
                <Text onPress={() => _selectValue(item)}>{item.name}</Text>
              </View>
            )
          }}
        />
      </View>
    )
  }
}

5. License

MIT Licensed. Copyright (c) TuanTVK 2019.