A simple iOS and Android picker for React Native
React Native Prefix Picker is simple, customizable and easy to use Picker in React Native. Works with both Android and IOS.
Now the prefixs are preloaded
npm i react-native-prefix-picker --save
import React, {
Component,
View,
Text,
} from 'react-native';
import { Select, Picker } from 'react-native-prefix-picker';
class Login extends Component {
constructor(props) {
super(props);
this.state = {
prefix: '',
};
}
render() {
return (
<View
style={{
flex: 1,
backgroundColor: 'white',
marginTop: 80,
padding: 20,
}}
>
<Select
ref="SELECT1"
pickerRef={() => this.refs.picker}
width={60}
height={45}
style={{
marginRight: 10,
padding: 6,
}}
styleText={{
color: '#333333',
fontSize: 20,
fontFamily: 'Avenir-Roman',
}}
selected={this.state.prefix}
/>
<Text
style={{
fontSize: 20,
textAlign: 'center',
margin: 10,
color: '#f87f1d',
}}
>
TEST
</Text>
<Picker
ref={'picker'}
selectedValue={'IT'}
onSubmit={(option) => {
this.setState({
prefix: option,
});
}}
/>
</View>
);
}
}
export default Login;
Property | Type | Default | Description |
---|---|---|---|
width | number | 200 | Width of the selection |
height | number | 40 | Height of the selection |
pickerRef | function | required | Reference to to display the selection menu |
selected | string | required | The value to be displayed. |
style | object | Custom styles to be applied if supplied | |
styleText | object | Custom styles to be applied if supplied | |
disabled | bool | false | If true, disable all interactions for this component. |
Property | Type | Default | Description |
---|---|---|---|
buttonColor | string | #007AFF | Custom styles to be applied if supplied. |
selectedValue | string | null | The default value. |
itemStyle | object | Custom styles to be applied if supplied. | |
onSubmit | function | required | function will be called when item button is pressed |
transparent | bool | false | Transparent style for Modal |