GithubHelp home page GithubHelp logo

nghiant96 / react-native-material-dropdown Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ppsplus-chablib/react-native-material-dropdown

0.0 0.0 0.0 195 KB

Material dropdown with consistent behaviour on iOS and Android

License: Other

JavaScript 74.81% Java 4.44% Objective-C 14.91% Starlark 5.83%

react-native-material-dropdown's Introduction

react-native-material-dropdown

npm license codeclimate

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
  • RTL support
  • 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

name description type default
label Text field label text String -
error Text field error text String -
animationDuration Text field animation duration in ms Number 225
fontSize Text field font size Number 16
labelFontSize Text field label font size Number 12
baseColor Text field base color String rgba(0, 0, 0, .38)
textColor Text field text color String rgba(0, 0, 0, .87)
itemColor Dropdown item text color (inactive item) String rgba(0, 0, 0, .54)
selectedItemColor Dropdown item text color (active item) String rgba(0, 0, 0, .87)
disabledItemColor Dropdown item text color (disabled item) String rgba(0, 0, 0, .38)
dropdownPosition Dropdown position (dynamic if undefined) Number -
itemCount Dropdown visible item count Number 4
itemPadding Dropdown item vertical padding Number 8
itemTextStyle Dropdown item text styles Object -
dropdownOffset Dropdown offset Object { top: 32, left: 0 }
dropdownMargins Dropdown margins Object { min: 8, max: 16 }
data Dropdown item data Array []
value Selected value String -
containerStyle Styles for container view Object -
overlayStyle Styles for overlay view Object -
pickerStyle Styles for item picker view Object -
shadeOpacity Shade opacity for dropdown items Number 0.12
rippleOpacity Opacity for ripple effect Number 0.54
rippleInsets Insets for ripple on base component Object { top: 16, bottom: -8 }
rippleCentered Ripple on base component should be centered Boolean false
renderBase Render base component Function -
renderAccessory Render text field accessory Function -
valueExtractor Extract value from item (args: item, index) Function ({ value }) => value
labelExtractor Extract label from item (args: item, index) Function ({ label }) => label
propsExtractor Extract props from item (args: item, index) Function () => null
onChangeText Selection callback (args: value, index, data) Function -

Other TextField, TextInput and TouchableWithoutFeedback properties will also work

Methods

name description returns
focus() Acquire focus (open dropdown) -
blur() Release focus (close dropdown) -
value() Get current value String
selectedIndex() Get selected index Number
selectedItem() Get selected item Object
isFocused() Get current focus state Boolean

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-2018 Alexander Nazarov. All rights reserved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.