1.4.2 • Published 4 years ago

react-native-easy-select v1.4.2

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

react-native-easy-select

NPM version License Update status

A flexible select component for React Native.

Demo

Table of Contents

Features

  • Easy to use
  • Easy to customize
  • Pure javascript
  • Lightweight package

Install

yarn add react-native-easy-select

or

npm i --save react-native-easy-select

Usage

import Selector from 'react-native-easy-select'; // Import package

const Example = () => (
  <Selector
    theme="dropdown" // Default: 'simple'
    items={[
      { myLabel: 'English', myValue: 'english' },
      { myLabel: 'French', myValue: 'french' },
    ]}

    // Specify key
    valueKey="myValue" // Default: 'value'
    labelKey="myLabel" // Default: 'label'

    defaultValue="english" // Set default value
    placeholder="Select a language" // Placeholder for dropdown UI

    loading={false} // Set loading for selector
    disabled ={false} // Set disable for selector

    // Styles
    textOptionStyle={{ color: 'green' }}
    placeholderContainerStyle={{ paddingVertical: 20 }}
    placeholderStyle={{ color: 'red' }}
    optionContainerStyle={{ backgroundColor: 'yellow' }}
    iconStyle={{ tintColor: 'black' }}
    loadingStyle={{ marginBottom: 10 }}

    // Change dropdown icon
    iconDropdownComponent={() => <AppText>Demo</AppText>}

    // On value change
    onChange={(value) => console.log(value)}
  />
);

export default Example;

Props

NameTypeDefaultDescription
itemsArray[]Required. The items for the component to render. You can specify value and label via valueKey and labelKey
onChangeFunction(value) => {}Required. Callback when the change the value button is pressed.
valueKeyString'value'Key name to specify value props of object
labelKeyString'label'Key name to specify label props of object
themeString = 'simple' or 'dropdown''simple'Required. Specify the UI for select components. Default is simple and dropdown UI is dropdown.
defaultValueString or Numer''Specify the default value of the selector. This value will be compared with the value of valueKey.
loadingString or NumerfalseShow ActivityIndicator when loading.
disabledString or NumerfalseDisable all interactions for selector.
iconDropdownComponentFunctionnullCustom icon component to be rendered.
defaultValueString or Numer''Specify the default value of the selector. This value will be compared with the value of valueKey.
placeholderString''Set placeholder for dropdown UI.
containerStyleObjectnullStyle overrides for container View of component.
optionContainerStyleObjectnullStyle overrides for View container of each option.
placeholderContainerStyleObjectnullStyle overrides for container View wrap of placeholder.
placeholderStyleObjectnullStyle overrides for Text of placeholder.
textOptionStyleObjectnullStyle overrides for Text of each option.
iconStyleObjectnullStyle overrides for icon component.
loadingStyleObjectnullStyle overrides for ActivityIndicator component.

Contribution

Contribution are always welcome and recommended! Here is how:

  • Fork the repository (here is the guide).
  • Clone to your machine git clone https://github.com/YOUR_USERNAME/react-native-easy-select.git
  • Make your changes
  • Create a pull request

License

react-native-easy-select is released under the MIT license. See LICENSE for details.

Any question or support will welcome.