1.1.2 • Published 12 months ago

@mustapha-ghlissi/react-native-select-picker v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

React Native Select Picker

@mustapha-ghlissi/react-native-select-picker: a Reanimated Picker Select for React Native.

MIT License npm npm npm npm github github github github

Screenshots

Simple Dropdown Custom Dropdown Advanced Dropdown Inline Dropdown

Demo

Demo

Example

You can check out this Example.

Installation

Installing the package

Use npm or yarn to install the package.

npm i @mustapha-ghlissi/react-native-select-picker
yarn add @mustapha-ghlissi/react-native-select-picker
Installing dependencies
npm i react-native-reanimated react-native-vector-icons
yarn add react-native-reanimated react-native-vector-icons

Note: to finish the installation, you have to finish configuring the installed dependencies react-native-reanimated and react-native-vector-icons.

Usage

import Dropdown from '@mustapha-ghlissi/react-native-select-picker';
import type {DropdownItem} from '@mustapha-ghlissi/react-native-select-picker';

const items: DropdownItem[] = [
    {
        label: 'Item 1',        
        value: 1
    },
    {
        label: 'Item 2',
        value: 2
    }
];

<Dropdown items={items}/>

Props

ParameterTypeDescription
itemsarray<DropdownItem>: requiredList of items
displayItemsnumber: optionalNumber of items to show in the dropdown
placeholderstring: optionalInputtext placeholder
stylesDropdownStyle : optionalDropdown styles
iconstring, ReactNode: optionalDropdown toggler icon
outlineColorstring: optionalDropdown outlineColor (default = '#000')
borderColorstring: optionalDropdown borderColor (default = '#EBEAEC')
borderWidthnumber: optionalBorder width used for the dropdown (default = 1)
inlineboolean: optionalDisplay th dropdown in inlined mode. ((default = false))
multipleboolean: optionalRender multi choice dropdown. ((default = false))
checkIconstring, ReactNode: optionalDisplay the icon when the option is checked. React native vector icons is used and MaterialCommunityIcons is used by default.
animationDurationnumber: optionalThe spending duration to toggle the dropdown. ((default = 200))
onSelectChangecallback: requiredCallback that returns the selected item/items (depending on multiple prop).

Types

DropdownStyle
ParameterTypeDescription
inputContainerViewStyle: optionalInputText Container style
inputTextTextStyle: optionalInputText field style
dropdownTogglerViewStyle: optionalDropdown Toggle style which wraps the InputText
iconContainerViewStyle: optionalIcon container style
dropdownListViewStyle: optionalDropdown list style
dropdownItemViewStyle: optionalDropdown list item style
dropdownItemTextViewStyle: optionalDropdown item text style
activeItemViewStyle: optionalActive item style
activeItemTextTextStyle: optionalActive item text style
DropdownItem
ParameterTypeDescription
labelstring: requiredOption label
valueany: requiredOption value

Advanced Usage

import Dropdown from '@mustapha-ghlissi/react-native-select-picker';
import type {DropdownItem} from '@mustapha-ghlissi/react-native-select-picker';
import Icon from 'react-native-vector-icons/Ionicons';


const items: DropdownItem[] = [
    {
        label: 'Item 1',        
        value: 1
    },
    {
        label: 'Item 2',
        value: 2
    }
];

<Dropdown 
    items={items}
    inline
    multiple
    icon={<Icon name="chevron-down" size={26} />}
    styles={{
        inputContainer:  {
            borderColor: '#DEDEDE',
        },
        inputText: {
            fontSize: 19,
            fontFamily: 'Montserrat-Medium',
        },
        activeItem: {
            backgroundColor: 'purple',
        },
        activeItemText: {
            color: '#FFF'
        }
    }}
/>

Donate

Donate with Wise by clicking this link or by scanning the QRCode

Wise

Authors

Other libraries