0.0.2 • Published 9 years ago

react-native-selectit v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

react-native-select

react-native-select lets you similar to html <select> choose one option between a set of other options.

Slider Examples

How to use react-native-select

Before you can use the component install it with npm:

npm i --save react-native-selectit

or install it from github.com:

npm i —save l-urence/react-native-select

Here is a small example of react-native-select:

var React = require('react-native');
var { Option, Select } = require('react-native-select');
var { AppRegistry, StyleSheet, View } = React;

var SelectExample = React.createClass({
  getInitialState() {
    return { layout: undefined };
  },

  render: function() {
    return (
      <View style={styles.container} onLayout={({nativeEvent: e}) =>
        this.setState({layout: e.layout})}
      >
        <Select parentLayout={this.state.layout} label="Character:">
          <Option value="han">Han Solo</Option>
          <Option value="leia">Princess Leia Organa</Option>
          <Option value="luke">Luke Skywalker</Option>
          <Option value="obiwan" default={true}>Obi-Wan Kenobi</Option>
        </Select>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    flex: 1,
    justifyContent: 'center'
  }
});

AppRegistry.registerComponent('SelectExample', () => SelectExample);

react-native-select props

Select

PropTypeDescription
childrenOptionSet of options to display
parentLayoutobjectThe layout of the parent element needs to be set for open / close animation
labelstringA label for the Select element
onSelectfunctionWill be called when selection changes onSelect={(value) => /* ... */}
selectedTextStylestyleSheetThe style for the selected option text

Option

PropTypeDescription
childrenstringThe option text which will be displayed
defaultboolThe option which will be displayed as selected
stylestyleSheetStyles will be applied to the option container
textStylestyleSheetStyles will be applied to to option text
valuestringThe actual option value