1.0.3 • Published 2 years ago

rn-simple-dropdown v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

rn-simple-dropdown

A simple dropdown component

Features

  • Pure js
  • Compatible with both iOS and Android.
  • Easy to customize item and style.

Installation

  npm i rn-simple-dropdown

or

  yarn add rn-simple-dropdown

Usage

 import Dropdown from 'rn-simple-dropdown';
 ...
  const DATA = [
   {key: '1', label: 1},
   {key: '2', label: 2},
   {key: '3', label: 3},
   {key: '4', label: 5},
   {key: '5', label: 6},
   {key: '6', label: 7},
   {key: '7', label: 8},
   {key: '8', label: 9},
   {key: '9', label: 10},
   {key: '10', label: 11},
   {key: '11', label: 12},
 ];
 ....
 <Dropdown data={DATA} placeholder="placeholder" maxHeightList={200} />

Props

nametypedefaultdescription
datarequire Array<{key:string|numner, label:string|number}>undefinedlist data
initValue{key:string|numner, label:string|number}undefinedinitial initialized value
placeholderstringundefinedThe string that will be rendered before dropdown has been selected
onChangefunction(val) => voidCallback that is called when the value be changed.
styleViewStylenullStyle is applied to dropdown
listContainerStyleViewStylenullStyle is applied to container of list
activeColorstring'#f5f5f5'backgroundcolor of active item
renderViewItemfunction(item, activeItem) => JSX.Element | undefinedCustom item function
iconViewanyright icon on dropdown
overlayColorstring'transparent'color of backdrop
maxHeightListnumberundefinedmax height to set list data can scroll
scrollStyleViewStyleundefinedstyle apply to scrollview of list data
textStyleTextStyleundefinedstyle apply to text value in dropdown
placeholderStyleTextStyleundefinedstyle aplly to placerholder text
redRefundefinedReference of dropdown

Method

namedescription
open()Open dropdown
close()Close dropdown
getValue()get value of selected item
setValue(item)set value for dropdown

Next version

Looking forward to your constructive comments and suggestions