0.1.6 • Published 5 years ago

react-native-material-dropdown-dgjoy v0.1.6

Weekly downloads
6
License
BSD-3-Clause
Repository
github
Last release
5 years ago

react-native-material-dropdown

npm license

Material dropdown with consistent behaviour on iOS and Android

example

Features

  • Easy to use
  • Consistent look and feel on iOS and Android
  • Customizable font size, colors and animation duration
  • Dynamic dropdown size and position
  • Configurable visible item count
  • Pure javascript implementation

Installation

npm install --save react-native-material-dropdown

Usage

import React, { Component } from 'react';
import { Dropdown } from 'react-native-material-dropdown';

class Example extends Component {
  render() {
    let data = [{
      value: 'Banana',
    }, {
      value: 'Mango',
    }, {
      value: 'Pear',
    }];

    return (
      <Dropdown
        label='Favorite Fruit'
        data={data}
      />
    );
  }
}

Properties

namedescriptiontypedefault
labelText field label text (required)String-
errorText field error textString-
animationDurationText field animation duration in msNumber225
fontSizeText field font sizeNumber16
labelFontSizeText field label font sizeNumber12
baseColorText field base colorStringrgba(0, 0, 0, .38)
itemColorDropdown item text color (inactive items)Stringrgba(0, 0, 0, .54)
textColorDropdown item text color (active item)Stringrgba(0, 0, 0, .87)
itemCountDropdown visible item countNumber4
dataDropdown item dataObject-
valueSelected valueString-
containerStyleStyles for container viewObject-
onChangeTextSelection callback (args: value, index, data)Function-

Other TextField and TextInput properties will also work

Methods

namedescriptionreturns
focus()Acquire focus (open dropdown)-
blur()Release focus (close dropdown)-
value()Get current valueString
selectedIndex()Get selected indexNumber
selectedItem()Get selected itemObject
isFocused()Get current focus stateBoolean

Example

git clone https://github.com/n4kz/react-native-material-dropdown
cd react-native-material-dropdown/example
npm install
npm run ios # or npm run android

Copyright and License

BSD License

Copyright 2017 Alexander Nazarov. All rights reserved.