Skip to content

Latest commit

 

History

History
172 lines (164 loc) · 5.38 KB

Picker.md

File metadata and controls

172 lines (164 loc) · 5.38 KB

picker-def-headref

Picker

Renders the native picker component on iOS and Android.
Replacing Component: React Native Picker

Preview ios picker-def-headref Preview android picker-def-headref

Contents:

Regular Syntax

import React, { Component } from "react";
import { Container, Header, Title, Content, Button, Icon, Right, Body, Left, Picker, Form } from "native-base";
export default class PickerExample extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selected1: "key1"
    };
  }
  onValueChange(value: string) {
    this.setState({
      selected1: value
    });
  }
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Button transparent onPress={() => this.props.navigation.goBack()}>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>Picker</Title>
          </Body>
          <Right />
        </Header>
        <Content>
          <Form>
            <Picker
              iosHeader="Select one"
              mode="dropdown"
              selectedValue={this.state.selected1}
              onValueChange={this.onValueChange.bind(this)}
            >
              <Picker.Item label="Wallet" value="key0" />
              <Picker.Item label="ATM Card" value="key1" />
              <Picker.Item label="Debit Card" value="key2" />
              <Picker.Item label="Credit Card" value="key3" />
              <Picker.Item label="Net Banking" value="key4" />
            </Picker>
          </Form>
        </Content>
      </Container>
    );
  }
}

Configuration

Property Default Option Description
renderHeader - - Makes component that appears as header of the Picker, comes with a backAction prop to close the picker.
headerStyle - - Custom style for header
iosHeader - - Custom text for the header title
headerBackButtonText - - Custom text for the header back button
headerBackButtonTextStyle - - Custom text style for the header back button
headerTitleStyle - - Custom title style for the header title
iosIcon - - Icon with picker dropdown
placeholder - - Placeholder for Picker component
placeholderStyle - - Custom style for placeholder text (iOS)
placeholderIconColor - - Set placeholder icon color (iOS)
itemStyle - - Style of items in Picker
itemTextStyle - - Text style of item component in Picker
textStyle - - Text style of header
supportedOrientations - Portrait, Landscape, Landscape-left, Landscape-right Allows the modal to rotate to any of the specified orientations

Note: Styling Picker is restricted to the style props provided in the table. NativeBase Picker wont support its styling to work out of the box. But one can always style the components as per requirements.