iOS Android

Components

NativeBase is made from effective building blocks referred to as components. The Components are constructed in pure React Native platform along with some JavaScript functionality with rich set of customisable properties. These components allow you to quickly build the perfect interface.

NativeBase includes components such as anatomy of your app screens, header, textbox, buttons, badge, icon, input, form, checkbox, radio-button, list, card, thumbnail, spinner, layout, search bar etc.


Anatomy

Automatically animates views to their new positions.
A common way to use NativeBase screen structure is to have all the components within <Container>.



General Syntax
import React, { Component } from 'react';
import { Container, Header, Title, Content, Footer, FooterTab, Button, Left, Right, Body, Icon } from 'native-base';
​
export default class AnatomyExample extends Component {
    render() {
        return (
            <Container>
                <Header>
                    <Left>
                        <Button transparent>
                            <Icon name='menu' />
                        </Button>
                    </Left>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right />
                </Header>

                <Content>
                    // Your main content goes here
                </Content>

                <Footer>
                    <FooterTab>
                        <Button full>
                            <Text>Footer</Text>
                        </Button>
                    </FooterTab>
                </Footer>
            </Container>
        );
    }
}


Configuration
Property Default Option Description
<Header> - - Renders as Header (navbar) of your screen.
Input values: Button, Title (Text). read more
<Content> - - Represents the main content of your screen.
There can be only one <Content> component in a screen.
<Footer> - - Renders as Footer of your screen.
Input values: FooterTab

Content

Syntax
import React, { Component } from 'react';
import { Container, Content } from 'native-base';
​
export default class ContentExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    // Your main content goes here
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
padder true true
false
Applies margin at all sides to Content section
Can be used with NativeBase View as well.
disableKBDismissScroll false true
false
Disables automatic scroll on focus


ActionSheet

NativeBase ActionSheet is a wrapper around the react-native ActionSheetIOS component.

Syntax
import React, { Component } from 'react';
import { Container, Content, ActionSheet, Button, Text, Header, Left, Right, Body, Title } from 'native-base';
​
var BUTTONS = [
  'Option 0',
  'Option 1',
  'Option 2',
  'Delete',
  'Cancel',
];
var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;

export default class ActionSheet extends Component {
  constructor(props) {
    super(props);
    this.state = {}
  }
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Button transparent>
              <Icon name="heart" size={20} color='red' />
            </Button>
          </Left>
          <Body>
            <Title>Hello</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Button onPress={()=> ActionSheet.show(
            {
              options: BUTTONS,
              cancelButtonIndex: CANCEL_INDEX,
              destructiveButtonIndex: DESTRUCTIVE_INDEX,
              title: 'Testing ActionSheet'
            },
            (buttonIndex) => {
              this.setState({ clicked: BUTTONS[buttonIndex] });
            }
            )}><Text>Actionsheet</Text></Button>
        </Content>
      </Container>
    );
  }
}

Note: The use caseis similar to RN's ActionSheetIOS.

Badge

All of us must have seen notification badges somewhere, such as on smart phones or facebook. NativeBase is here to include this into your collection of readymade components. Badges are numerical indicators of how many items are associated with an element. Badges can notify you that there are new or unread messages or notifications. These can be very effective in alerting the user to new things on your app.

Syntax
import React, { Component } from 'react';
import { Container, Content, Badge, Text, Icon } from 'native-base';
​
export default class BadgeExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Badge>
                        <Text>2</Text>
                    </Badge>
                    <Badge primary>
                        <Text>2</Text>
                    </Badge>
                    <Badge success>
                        <Text>2</Text>
                    </Badge>
                    <Badge info>
                        <Text>2</Text>
                    </Badge>
                    <Badge warning>
                        <Text>2</Text>
                    </Badge>
                    <Badge danger>
                        <Text>2</Text>
                    </Badge>
                    <Badge primary>
                        <Icon name="star" />
                    </Badge>
                    <Badge
                      style={{ backgroundColor: 'black' }}>
                        <Text>1866</Text>
                    </Badge>
                </Content>
            </Container>
        );
    }
}



Button

Button is a pure NativeBase component.
Buttons are the integral part of an application. They are used for various purposes like, submit or reset a form, navigate, performing interactive actions such as showing or hiding something in an app on click of the button, etc.



Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class ButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    // NativeBase default style
                    <Button>
                        <Text>Click Me! </Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}


Configuration
Property Default Option Description
style - - Defines button style
active - true
Boolean value to describe state of Button
block - - Block level button
bordered - - Applies outline button style.
disabled true true
false
Disables click option for button
large - - For large size button
rounded - - Renders button with slightly round shaped edges.
small - - For small size button
full - - full width button
iconRight - - Right Padding for the icon.
iconLeft - - Left Padding for the icon.

Button Theme

NativeBase provides buttons with wide range of colors, size and variuos other props.
NativeBase provides following color themes:

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class ButtonThemeExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button light><Text> Light </Text></Button>
                    <Button primary><Text> Primary </Text></Button>
                    <Button success><Text> Success </Text></Button>
                    <Button info><Text> Info </Text></Button>
                    <Button warning><Text> Warning </Text></Button>
                    <Button danger><Text> Danger </Text></Button>
                    <Button dark><Text> Dark </Text></Button>
                </Content>
            </Container>
        );
    }
}


Block Button

A block level button spans the entire width of the parent element. Create block level buttons by adding block prop with the Button.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class BlockButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button light block>
                        <Text>Light</Text>
                    </Button>
                    <Button block>
                        <Text>Primary</Text>
                    </Button>
                    <Button block success>
                        <Text>Success</Text>
                    </Button>
                    <Button block info>
                        <Text>Info</Text>
                    </Button>
                    <Button block warning>
                        <Text>Warning</Text>
                    </Button>
                    <Button block danger>
                        <Text>Danger</Text>
                    </Button>
                    <Button dark block>
                        <Text>Dark</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

Full Button

Adding full to a button will make the button take 100% of its parent’s width. However, it will also remove the button’s left and right borders. This style is useful when the button should stretch across the entire width of the display.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class FullButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                <Button light full>
                    <Text>Light</Text>
                </Button>
                <Button full>
                    <Text>Primary</Text>
                </Button>
                <Button full success>
                    <Text>Success</Text>
                </Button>
                <Button full info>
                    <Text>Info</Text>
                </Button>
                <Button full warning>
                    <Text>Warning</Text>
                </Button>
                <Button full danger>
                    <Text>Danger</Text>
                </Button>
                <Button dark full>
                    <Text>Dark</Text>
                </Button>
                </Content>
            </Container>
        );
    }
}

Rounded Button

Include rounded prop with Button to easily style your buttons.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class RoundedButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button light rounded>
                        <Text>Light</Text>
                    </Button>
                    <Button rounded>
                        <Text>Primary</Text>
                    </Button>
                    <Button rounded success>
                        <Text>Success</Text>
                    </Button>
                    <Button rounded info>
                        <Text>Info</Text>
                    </Button>
                    <Button rounded warning>
                        <Text>Warning</Text>
                    </Button>
                    <Button rounded danger>
                        <Text>Danger</Text>
                    </Button>
                    <Button dark rounded>
                        <Text>Dark</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

Icon Button

The Icon Buttons, can take text and/or icon as child elements inside the Button. read more
This goes as simple as this: include your choice of icon using Icon component within the Button component.
The components in button renders in the order of their definition.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Icon, Text } from 'native-base';
​
export default class IconButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button iconLeft light>
                        <Icon name='arrow-back' />
                        <Text>Back</Text>
                    </Button>

                    <Button iconRight light>
                        <Text>Next</Text>
                        <Icon name='arrow-forward' />
                    </Button>

                    <Button iconLeft>
                        <Icon name='home' />
                        <Text>Home</Text>
                    </Button>

                    <Button transparent primary iconLeft>
                        <Icon name='beer' />
                        <Text>Pub</Text>
                    </Button>

                    <Button dark iconLeft>
                        <Icon name='cog' />
                        <Text>Settings</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

Outline Button

Include bordered prop with Button to apply outline button style.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class OutlineButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button outline light bordered>
                        <Text>Light</Text>
                    </Button>
                    <Button bordered>
                        <Text>Primary</Text>
                    </Button>
                    <Button bordered success>
                        <Text>Success</Text>
                    </Button>
                    <Button bordered info>
                        <Text>Info</Text>
                    </Button>
                    <Button bordered warning>
                        <Text>Warning</Text>
                    </Button>
                    <Button bordered danger>
                        <Text>Danger</Text>
                    </Button>
                    <Button dark bordered danger>
                        <Text>Dark</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

Transparent Button

Include transparent prop with Button. This will render button without border and background color.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text, Icon } from 'native-base';
​
export default class TransparentButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                <Button light transparent>
                    <Text>Light</Text>
                </Button>
                <Button transparent>
                    <Text>Primary</Text>
                </Button>
                <Button transparent success>
                    <Text>Success</Text>
                </Button>
                <Button transparent info>
                    <Text>Info</Text>
                </Button>
                <Button transparent warning>
                    <Text>Warning</Text>
                </Button>
                <Button transparent danger>
                    <Text>Danger</Text>
                </Button>
                <Button dark transparent>
                    <Text>Dark</Text>
                </Button>
                </Content>
            </Container>
        );
    }
}

Button Size

Want to have buttons of fancy size?
Include the following props with your Button.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class ButtonSizeExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    //Small size button
                    <Button small primary>
                        <Text>Default Small</Text>
                    </Button>

                    //Regular size button
                    <Button success>
                        <Text>Success Default</Text>
                    </Button>

                    //Large size button
                    <Button large info>
                        <Text>Dark Large</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

Disabled Button

A disabled button is unusable and un-clickable.
The disabled prop of NativeBase Button is of type boolean. When present, it specifies that the button should be disabled. The disabled prop can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.). Then, a conditional code could remove the disabled value, and make the button usable.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class DisabledButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                <Button disabled><Text>Solid</Text></Button>
                <Button bordered disabled><Text>Bordered</Text></Button>
                <Button rounded disabled><Text>rounded</Text></Button>
                <Button large disabled><Text>Custom</Text></Button>
                <Button disabled iconRight>
                    <Text>Icon Button</Text>
                    <Icon name="home" />
                </Button>
                <Button block disabled style={styles.mb15}><Text>Block</Text></Button>
                <Button full disabled style={styles.mb15}><Text>Block</Text></Button>
                </Content>
            </Container>
        );
    }
}


Card

Card is a pure NativeBase component.
Card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.
NativeBase Cards support a wide variety of content, including images, text, list groups, links, and more. Mix and match multiple content types to create the card you need.



Genertal Syntax
import React, { Component } from 'react';
import { Container, Content, Card, CardItem, Body, Text } from 'native-base';
​
export default class CardExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card>
                        <CardItem>
                            <Body>
                                <Text>
                                    //Your text here
                                </Text>
                            </Body>
                        </CardItem>
                    </Card>
                </Content>
            </Container>
        );
    }
}


Configuration
Property Default Option Description
button - - To navigate on click of a card item.
cardBody - - Defines section for body of card.
The child components are rendered with proper spacing and alignment.
footer - - Displays text as footer for cards
header - - Displays text as header for cards
bordered false true
false
To add border to the cardItems

Card Header and Footer

To add an optional header and/or footer within a card, include header prop with the CardItem.

Syntax
import React, { Component } from 'react';
import { Container, Content, Card, CardItem, Text, Body } from 'native-base';
​
export default class CardHeaderFooterExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card>
                        <CardItem header>
                            <Text>NativeBase</Text>
                        </CardItem>

                        <CardItem>
                            <Body>
                                <Text>
                                    //Your text here
                                </Text>
                            </Body>
                        </CardItem>
                        <CardItem footer>
                            <Text>GeekyAnts</Text>
                        </CardItem>
                   </Card>
                </Content>
            </Container>
        );
    }
}

Card List

Include CardItem subsequently within Card to create a card with lists.

Syntax
import React, { Component } from 'react';
import { Container, Content, Card, CardItem, Text, Icon, Right, Left, Body } from 'native-base';
​
export default class CardListExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card>
                    <CardItem>
                       <Icon active name="logo-googleplus" />
                       <Text>Google Plus</Text>
                       <Right>
                          <Icon name="arrow-forward" />
                       </Right>
                     </CardItem>
                   </Card>
                </Content>
            </Container>
        );
    }
}

Card Image

Want to have something more with Card Lists?
Include image with CardItem within Card along with some text before and after image to create a card with lists.
Here is your Card Image ready !

Syntax
import React, { Component } from 'react';
import { Image } from 'react-native';
import { Container, Content, Card, CardItem, Left, Body Thumbnail, Text, Button, Icon } from 'native-base';
​
export default class CardImageExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card >
                        <CardItem>
                            <Left>
                                <Thumbnail source={logo} />
                                <Body>
                                    <Text>NativeBase</Text>
                                    <Text note>GeekyAnts</Text>
                                </Body>
                            </Left>
                          </CardItem>
                          <CardItem cardBody>
                              <Image/>
                          </CardItem>
                          <CardItem content>
                              <Text>Wait a minute. Wait a minute, Doc. Uhhh...
                              Are you telling me that you built a time machine... out of a DeLorean?!
                              Whoa. This is heavy.</Text>
                          </CardItem>
                          <CardItem style={{ justifyContent: 'space-around' }}>
                              <Button transparent>
                                  <Icon active name="thumbs-up" />
                                  <Text>12 Likes</Text>
                              </Button>
                              <Button transparent>
                                  <Icon active name="chatbubbles" />
                                  <Text>4 Comments</Text>
                              </Button>
                              <Text>11h ago</Text>
                        </CardItem>
                   </Card>
                </Content>
            </Container>
        );
    }
}

Card Showcase

Card Showcase is further customization of Card Image. It uses several different items.

Syntax
import React, { Component } from 'react';
import { Image } from 'react-native';
import { Container, Content, Card, CardItem, Left, Body Thumbnail, Text, Button, Icon } from 'native-base';
​
export default class CardShowcaseExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Card>
                        <CardItem bordered>
                            <Left>
                                <Thumbnail />
                                <Body>
                                  <Text>NativeBase</Text>
                                  <Text note>April 15, 2016</Text>
                                </Body>
                            </Left>
                        </CardItem>

                        <CardItem>
                            <Body>
                                <Image style={{ resizeMode: 'cover' }} source={require('./img/card-showcase.png')} />
                                <Text>
                                    //Your text here
                                </Text>
                                <Button transparent textStyle={{color: '#87838B'}}>
                                    <Icon name="logo-github" />
                                    <Text>1,926 stars</Text>
                                </Button>
                            </Body>
                        </CardItem>
                   </Card>
                </Content>
            </Container>
        );
    }
}


Check Box

Check Box allows the user to select a number of items from a set of choices.
Replacing Component: React Native <TouchableOpacity>

Syntax
import React, { Component } from 'react';
import { Container, Content, Body, ListItem, Text, CheckBox } from 'native-base';
​
export default class CheckBoxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem>
                        <CheckBox checked={true} />
                        <Body>
                            <Text>Daily Stand Up</Text>
                        </Body>
                    </ListItem>
                    <ListItem>
                        <CheckBox checked={false} />
                        <Body>
                            <Text>Discussion with Client</Text>
                        </Body>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
checked false true
false
Represents the state value of an item from set of choices.


Deck Swiper

Looking at data one piece at a time is more efficient when you consider people you might want to date, restaurants, streaming music, or local events you might want to check out.
NativeBase Deck Swiper helps you evaluate one option at a time, instead of selecting from a set of options.
Replacing Component: React Native <View>

Syntax
import React, { Component } from 'react';
import { Image, View } from 'react-native';
import { Container, Icon, DeckSwiper, Card, CardItem, Left, Body, Thumbnail, Text } from 'native-base';

const cards = [
    {
        text: 'Card One',
        name: 'One',
        image: require('./img/swiper-1.png'),
    },
    .  .  .
];

export default class DeckSwiperExample extends Component {

    render() {
        return (
            <Container>
                <View>
                    <DeckSwiper
                        dataSource={cards}
                        renderItem={item =>
                            <Card style={{ elevation: 3 }}>
                                <CardItem>
                                    <Left>
                                        <Thumbnail source={item.image} />
                                    </Left>
                                    <Body>
                                        <Text>{item.text}</Text>
                                        <Text note>NativeBase</Text>
                                    </Body>
                                </CardItem>
                                <CardItem cardBody>
                                    <Image style={{ resizeMode: 'cover', width: null, flex: 1, height: 300 }} source={item.image} />
                                </CardItem>
                                <CardItem>
                                    <Icon name="heart" style={{ color: '#ED4A6A' }} />
                                    <Text>{item.name}</Text>
                                </CardItem>
                            </Card>
                        }
                    />
                </View>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
onSwipeRight Function - Callback that is called when the Card is Swipe Right
onSwipeLeft Function - Callback that is called when the Card is Swipe Left


FABs

FABs (Floating Action Buttons) are used for a special type of promoted action. They are distinguished by a circled icon floating above the UI in a fixed position and have special motion behaviors. When clicked, it may contain more related actions.
Replacing Component: React Native <Animated>


Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Icon, Fab, View } from 'native-base';
​
export default class FABExample extends Component {
    constructor() {
        this.state = {
            active: 'true'
        };
    }

    render() {
        return (
            <Container>
                <View>
                    <Fab
                        active={this.state.active}
                        direction="up"
                        style={{ backgroundColor: '#5067FF' }}
                        position="bottomRight"
                        onPress={() => this.setState({ active: !this.state.active })}
                    >
                        <Icon name="share" />
                        <Button style={{ backgroundColor: '#34A34F' }}>
                            <Icon name="logo-whatsapp" />
                        </Button>
                        <Button style={{ backgroundColor: '#3B5998' }}>
                            <Icon name="logo-facebook" />
                        </Button>
                        <Button disabled style={{ backgroundColor: '#DD5144' }}>
                            <Icon name="mail" />
                        </Button>
                    </Fab>
                </View>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
active - true
false
Toggle status of FAB (initial status)
containerStyle - user-defined Padding options to render FAB.
direction up up, down, left, right Direction of Buttons that popup on click of FAB.
onPress - user-defined Toggle status of FAB (negated value of initial status)
position bottomRight topLeft, topRight
bottomLeft, bottomRight
Position of FAB on screen.
style - user-defined User defined styles.

Multiple FABs

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Icon, Fab, Text, View } from 'native-base';
​
export default class FABExample extends Component {
    constructor() {
        this.state = {
            active: 'true'
        };
    }

    render() {
        return (
            <Container>
                <View>
                    <Fab
                        active={this.state.active}
                        direction="up"
                        containerStyle={ marginLeft: 10 }}
                        style={{ backgroundColor: '#5067FF' }}
                        position="bottomRight"
                        onPress={() => this.setState({ active: !this.state.active })}
                    >
                      ....
                    </Fab>

                    <Fab direction="left" position="topRight">
                      ....
                    </Fab>

                    <Fab direction="down" position="topLeft">
                      ....
                    </Fab>

                    <Fab direction="right" position="bottomLeft">
                      ....
                    </Fab>
                </View>
            </Container>
        );
    }
}


Footer Tabs

Tabs are a horizontal region of buttons or links that allow for a consistent navigation experience between screens. It can contain any combination of text and icons, and is a popular method for enabling mobile navigation.
Replacing Component: React Native <View>


Syntax
import React, { Component } from 'react';
import { Container, Content, Footer, FooterTab, Button, Icon, Text } from 'native-base';
​
export default class FooterTabsExample extends Component {
    render() {
        return (
            <Container>
                <Content />

                <Footer >
                    <FooterTab>
                        <Button>
                            <Text>Apps</Text>
                        </Button>
                        <Button>
                            <Text>Camera</Text>
                        </Button>
                        <Button active>
                            <Text>Navigate</Text>
                        </Button>
                        <Button>
                            <Text>Contact</Text>
                        </Button>
                    </FooterTab>
                </Footer>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
badgeValue - user-defined This is Button prop (applicable with FooterTab only)
Value of badge to be displayed
badgeValueStyle white user-defined This is Button prop (applicable with FooterTab only)
Font color of badge text
badgeColor red user-defined This is Button prop (applicable with FooterTab only)
Background color of badge

Icon Footer


Syntax
import React, { Component } from 'react';
  import { Container, Content, Footer, FooterTab, Button, Icon, Text } from 'native-base';
  ​
  export default class FooterTabsExample extends Component {
      render() {
          return (
              <Container>
                  <Content />

                  <Footer >
                      <FooterTab>
                          <Button>
                              <Icon name="apps" />
                          </Button>
                          <Button>
                              <Icon name="camera" />
                          </Button>
                          <Button active>
                              <Icon active name="navigate" />
                          </Button>
                          <Button>
                              <Icon name="person" />
                          </Button>
                      </FooterTab>
                  </Footer>
              </Container>
          );
      }
  }

Icon Footer with Text


Syntax
import React, { Component } from 'react';
  import { Container, Content, Footer, FooterTab, Button, Icon, Text } from 'native-base';
  ​
  export default class FooterTabsExample extends Component {
      render() {
          return (
              <Container>
                  <Content />

                  <Footer >
                      <FooterTab>
                          <Button>
                              <Icon name="apps" />
                              <Text>Apps</Text>
                          </Button>
                          <Button>
                              <Icon name="camera" />
                              <Text>Camera</Text>
                          </Button>
                          <Button active>
                              <Icon active name="navigate" />
                              <Text>Navigate</Text>
                          </Button>
                          <Button>
                              <Icon name="person" />
                              <Text>Contact</Text>
                          </Button>
                      </FooterTab>
                  </Footer>
              </Container>
          );
      }
  }

Footer with badge


Syntax
import React, { Component } from 'react';
  import { Container, Content, Footer, FooterTab, Button, Icon, Text } from 'native-base';
  ​
  export default class FooterTabsExample extends Component {
      render() {
          return (
              <Container>
                  <Content />

                  <Footer >
                      <FooterTab>
                          <Button badge>
                              <Badge><Text>2</Text></Badge>
                              <Icon name="apps" />
                              <Text>Apps</Text>
                          </Button>
                          <Button>
                              <Icon name="camera" />
                              <Text>Camera</Text>
                          </Button>
                          <Button active badge>
                              <Badge style={{ backgroundColor: 'blue' }}><Text>51</Text></Badge>
                              <Icon active name="navigate" />
                              <Text>Navigate</Text>
                          </Button>
                          <Button>
                              <Icon name="person" />
                              <Text>Contact</Text>
                          </Button>
                      </FooterTab>
                  </Footer>
              </Container>
          );
      }
  }


Form

NativeBase makes use of Form component to design Forms that include group of related input Item components. Include any combination of NativeBase Item components to make up your form.

Input is a NativeBase component built on top of React Native's <TextInput>. Item component is wrap around it apply the specific styles.
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto-correction, auto-capitalization, placeholder text, and different keyboard types, such as a numeric keypad. Provides a number of attributes that follows styling and interaction guidelines for each platform, so that they are intuitive for users to interact with.


Note: Form in native base is just a wrapper around the inputs and hence has no onSubmit function.


Syntax
import React, { Component } from 'react';
import { Container, Content, Form, Item, Input } from 'native-base';

export default class FormExample extends Component {

    render() {
        return (
            <Container>
                <Content>
                    <Form>
                        <Item>
                            <Input placeholder="Username" />
                        </Item>
                        <Item last>
                            <Input placeholder="Password" />
                        </Item>
                    </Form>
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
fixedLabel - - Label is Fixed to the left of the Input and does not hide when text is entered.
floatingLabel - - Label that animates upwards when the input is selected and animates downward when input is erased.
inlineLabel - - Label placed to the left of the input element. When the user enters text, the label does not hide. This can also be used along with placeholder.
stackedLabel - - Places the label on top of the input element which appears like a stack. This can also be used along with placeholder.
placeholderLabel - - Renders the same way the TextInput does with the form styling of NativeBase.
bordered - - Includes border with the textbox.
rounded - - Includes rounded border with the textbox.
underline true - Includes and underline border with the textbox.
disabled - - Disables inputting data.
error - - The border color of textbox for invalid input.
placeholder - - The string that will be rendered before text input has been entered. Optional user-defined placeholder for textbox.
secureTextEntry false true
false
If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
This prop can be passed to <Input>.
success - - The border color of textbox for valid input.
last - - Style the Form Item for the last Item of the Form.

Fixed Label

The fixedLabel property creates a Input component, whose Label is fixed at the left of the Input, which does not hide when text is entered. The input aligns on the same position, regardless of the length of the label. It can be used with placeholder as well.

Syntax
import React, { Component } from 'react';
    import { Container, Content, Form, Item, Input, Label } from 'native-base';

    export default class FormExample extends Component {

        render() {
            return (
                <Container>
                    <Content>
                        <Form>
                            <Item fixedLabel>
                                <Label>Username</Label>
                                <Input />
                            </Item>
                            <Item fixedLabel last>
                                <Label>Password</Label>
                                <Input />
                            </Item>
                        </Form>
                    </Content>
                </Container>
            );
        }
    }

Inline Label

The inlineLabel property creates a Input component, whose Label is in-line with Input, which does not hide when text is entered. It can be used with placeholder as well.

Syntax
import React, { Component } from 'react';
    import { Container, Content, Form, Item, Input, Label } from 'native-base';

    export default class FormExample extends Component {

        render() {
            return (
                <Container>
                    <Content>
                        <Form>
                            <Item inlineLabel>
                                <Label>Username</Label>
                                <Input />
                            </Item>
                            <Item inlineLabel last>
                                <Label>Password</Label>
                                <Input />
                            </Item>
                        </Form>
                    </Content>
                </Container>
            );
        }
    }

Floating Label

The floatingLabel property creates a Input component, whose Label animates upwards when the input text is entered and animates downward when input text is erased.

Syntax
import React, { Component } from 'react';
    import { Container, Content, Form, Item, Input, Label } from 'native-base';

    export default class FormExample extends Component {

        render() {
            return (
                <Container>
                    <Content>
                        <Form>
                            <Item floatingLabel>
                                <Label>Username</Label>
                                <Input />
                            </Item>
                            <Item floatingLabel last>
                                <Label>Password</Label>
                                <Input />
                            </Item>
                        </Form>
                    </Content>
                </Container>
            );
        }
    }

Stacked Label

The stackedLabel property creates a Input component, whose Label is placed at the top of the Input which appears like a stack. It can be used with placeholder as well.

Syntax
import React, { Component } from 'react';
    import { Container, Content, Form, Item, Input, Label } from 'native-base';

    export default class FormExample extends Component {

        render() {
            return (
                <Container>
                    <Content>
                        <Form>
                            <Item stackedLabel>
                                <Label>Username</Label>
                                <Input />
                            </Item>
                            <Item stackedLabel last>
                                <Label>Password</Label>
                                <Input />
                            </Item>
                        </Form>
                    </Content>
                </Container>
            );
        }
    }

Regular Textbox

To use the regular textbox which is rectangular in shape, include the regular prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input } from 'native-base';
​
export default class RegularTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>​
                    // Simple rectangular text input box
                    <Item regular>
                        <Input placeholder='Regular Textbox'/>
                    </Item>
                </Content>
            </Container>
        );
    }
}

Underlined Textbox

To use the underlined textbox, include the underline prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class UnderlinedTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>​
                    // Underlined text input box with placeholder text
                    <Item underline>
                        <Input placeholder='Underlined Textbox' />
                    </Item>
                </Content>
            </Container>
        );
    }
}

Rounded Textbox

To have a textbox with round type border, include the rounded prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class RoundedTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    // Rounded text input box
                    <Item rounded>
                        <Input placeholder='Rounded Textbox'/>
                    </Item>
                </Content>
            </Container>
        );
    }
}

Icon Textbox

Icons can be easily added to the NativeBase Textbox. To do so, include an icon within the Item.
The components in textbox renders in the order of their definition.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class IconTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    // Text input box with icon aligned to the left
                    <Item>
                        <Icon active name='home' />
                        <Input placeholder='Icon Textbox'/>
                    </Item>

                    // Text input box with icon aligned to the right
                    <Item>
                        <Input placeholder='Icon Alignment in Textbox'/>
                        <Icon active name='swap' />
                    </Item>
                </Content>
            </Container>
        );
    }
}

Success Input Textbox

To display textbox with valid data, include the success prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class SuccessInputTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Item success>
                        <Input placeholder='Textbox with Success Input'/>
                        <Icon name='checkmark-circle' />
                    </Item>
                </Content>
            </Container>
        );
    }
}

Error Input Textbox

To display textbox with invalid data, include the error prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class ErrorInputTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Item error>
                        <Input placeholder='Textbox with Error Input'/>
                        <Icon name='close-circle' />
                    </Item>
                </Content>
            </Container>
        );
    }
}

Disabled Textbox

To restrict inputting data into textbox, include the disabled prop.

Syntax
import React, { Component } from 'react';
import { Container, Content, Item, Input, Icon } from 'native-base';
​
export default class DisabledTextboxExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Item disabled>
                        <Input disabled placeholder='Disabled Textbox'/>
                        <Icon name='information-circle' />
                    </Item>
                </Content>
            </Container>
        );
    }
}


Header


Syntax
import React, { Component } from 'react';
import { Container, Header, Title, Button, Left, Right, Body, Icon } from 'native-base';
​
export default class HeaderExample extends Component {
    render() {
        return (
            <Container>
                <Header>
                    <Left>
                        <Button transparent>
                            <Icon name='arrow-back' />
                        </Button>
                    </Left>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right>
                        <Button transparent>
                            <Icon name='menu' />
                        </Button>
                    </Right>
                </Header>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
<Left> - - Components render to the left in Header
<Body> - - Components render at the center of Header
<Right> - - Components render to the right in Header
noShadow false true
false
To remove border and elevation from iOS and Android respectively
iosBarStyle - 'light-content', 'dark-content' or 'default' Set iOS barStyle
backgroundColor - string Set android statusBar color

Header with only title

Syntax
import React, { Component } from 'react';
    import { Container, Header, Title, Button, Left, Right, Body, Icon } from 'native-base';
    ​
    export default class HeaderExample extends Component {
    render() {
        return (
            <Container>
                <Header>
                    <Left/>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right />
                </Header>
            </Container>
        );
    }
    }

Header with Icon and Text Buttons

Syntax
import React, { Component } from 'react';
    import { Container, Header, Title, Button, Left, Right, Body, Icon } from 'native-base';
    ​
    export default class HeaderExample extends Component {
    render() {
    return (
        <Container>
            <Header>
                <Left>
                    <Button transparent>
                        <Icon name='arrow-back' />
                    </Button>
                </Left>
                <Body>
                    <Title>Header</Title>
                </Body>
                <Right>
                    <Text>Cancel</Text>
                </Right>
            </Header>
        </Container>
    );
    }
    }

Header with Title and Subtitle

Syntax
import React, { Component } from 'react';
    import { Container, Header, Title, Button, Subtitle, Left, Right, Body, Icon } from 'native-base';
    ​
    export default class HeaderExample extends Component {
    render() {
    return (
        <Container>
            <Header>
                <Left>
                    <Button transparent>
                        <Icon name='arrow-back' />
                    </Button>
                </Left>
                <Body>
                    <Title>Title</Title>
                    <Subtitle>Subtitle</Subtitle>
                </Body>
                <Right />
            </Header>
        </Container>
    );
    }
    }


Icon

Icons in native base use Ionicons as the default icon family. Additionally we've also mapped the Icons to their respective platforms. So <Icon name="search" /> will render <Icon name="ios-search" /> on iPhones and <Icon name="md-search" /> on android devices. For icons which do not have the ios/md prefix, it will fall back to the name . So <Icon name="logo-facebook" /> will return the same Icon component on both android and iOS (this also holds true for all the other icon families).

Syntax
import React, { Component } from 'react';
import { Container, Content, Icon } from 'native-base';
​
export default class IconExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Icon active name='logo-apple' />
                    <Icon ios='ios-pizza-outline' android="md-pizza" style={{color: '#ffc125'}}/>
                    <Icon active name='ios-person' />
                </Content>
            </Container>
        );
    }
}


Configuration
Property Default Option Description read more
name - - Name of the icon.
ios - - Name of the icon for iOS Platform.
android - - Name of the icon for Android Platform.
active default true
fasle
Renders filled Icons
Note: By default it renders outline Icons
color black user-defined Renders icon with defined color.
Note: Include this prop within style
fontSize 27 user-defined Renders icon with defined icon-size.
Note: Include this prop within style


Layout

The layout system is an essential concept that needs to be mastered in order to create great layouts and UIs. React Native uses Flexbox to create the layouts, which is great when we need to accommodate our components and views in different screen sizes or even different devices. Flexbox is awesome but it could be tiresome for newbies.

Not being very good at Flexbox?
Here comes the Easy Grid of NativeBase, a wrapper of Flexbox.


The layout system in NativeBase is very powerful and flexible. No more worries about props of Flexbox such as alignItems, flexDirection, justifyContent, margin, padding, position, width etc. You can create any layout with all the available options that we have. In order to build custom layouts and components, understanding how layout works in NativeBase is not as hard as Flexbox. Flexbox makes it look like percentages, however what actually is happening is just ratios. On the easier part, ratios are easier to represent than percentage/decimals. For this reason, the Easy Grid takes in ratios in place of percentage.
Performance wise, Easy Grid is noteworthy and works as fine as Flexbox, not much of calculation.

Syntax
import React, { Component } from 'react';
import { Container, Content } from 'native-base';
import { Col, Row, Grid } from 'react-native-easy-grid';
​
export default class LayoutExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Grid>
                        <Col style={{ backgroundColor: '#635DB7', height: 200 }}></Col>
                        <Col style={{ backgroundColor: '#00CE9F', height: 200  }}></Col>
                    </Grid>
                </Content>
            </Container>
        );
    }
}

NOTE: <Content> component uses <ScrollView>. This is required by <Col> and <Row> elements of Easy-Grid to have a defined height.



List

List is a replacement for the ListView of React Native. A base component for specifying lists of information. List must contain one or more list elements. Props provide configurability for several features. Provides a number of attributes that follows styling and interaction guidelines for each platform, so that they are intuitive for users to interact with.


Note: List in NativeBase 2.0, takes dataArray as its prop like in it's older versions.


Syntax
import React, { Component } from 'react-native';
import { Container, Content, ListItem, Text } from 'native-base';
​
export default class ListExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem>
                        <Text>Simon Mignolet</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Nathaniel Clyne</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Dejan Lovren</Text>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}


Configuration
Property Default Option Description
button - - To navigate on click of a list item.
dataArray Array user-defined array Array of data chunks to render iteratively.
itemDivider - - Helps to organize and group the list items.
itemHeader - - Style the item as the header for the ListItems.
first - - Render as the first Item in the List.
first - - Render as the last Item in the List.
icon - - To have list styling of icons .
avatar - - Style the list to have Avatars.
thumnail - - Style the list to have Thumbnails.
renderRow Function - Callback which takes a chunk of data from dataArray and returns as a component.

List Divider

The List Divider component creates a list separator, which can be used for grouping list items. To create a divider for any child element of the list, include itemDivider prop with ListItem component. The List Divider of NativeBase comes with default style which is easily customisable.

Syntax
import React, { Component } from 'react';
import { Container, Content, ListItem, Text } from 'native-base';
​
export default class ListDividerExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem itemDivider>
                        <Text>A</Text>
                    </ListItem>
                    <ListItem >
                        <Text>Aaron Bennet</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Ali Connors</Text>
                    </ListItem>
                    <ListItem itemDivider>
                        <Text>B</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Bradley Horowitz</Text>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

List Header

The List Header component creates a list header, which can be used for grouping list items. To create a header for any child element of the list, include itemHeader prop with ListItem component. The List Header of NativeBase comes with default style which is easily customisable.

Syntax
import React, { Component } from 'react';
import { Container, Content, ListItem, Text } from 'native-base';
​
export default class ListDividerExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem itemHeader first>
                        <Text>COMEDY</Text>
                    </ListItem>
                    <ListItem >
                        <Text>Hangover</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Horrible Bosses</Text>
                    </ListItem>
                    <ListItem last>
                        <Text>Conjuring</Text>
                    </ListItem>
                    <ListItem itemHeader>
                        <Text>ACTION</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Terminator Genesis</Text>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

List Icon

Lists can have icons assigned either to the left and/or right side of each list item. Along with icons, list item can also have badges assigned. To have note kind of text for list item, include note prop with Text component of ListItem.

Syntax
import React, { Component } from 'react-native';
import { Container, Content, ListItem, Left, body, Right, Switch, Radio, Text, Icon, Badge } from 'native-base';
​
export default class ListIconExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem icon>
                        <Left>
                            <Icon name="plane" />
                        </Left>
                        <Body>
                          <Text>Airplane Mode</Text>
                        </Body>
                        <Right>
                            <Switch valur={false} />
                        </Right>
                    </ListItem>
                    <ListItem icon>
                        <Left>
                            <Icon name="wifi" />
                        </Left>
                        <Body>
                          <Text>Wi-Fi</Text>
                        </Body>
                        <Right>
                            <Text>GeekyAnts</Text>
                            <Icon name="arrow-forward" />
                        </Right>
                    </ListItem>
                    <ListItem icon>
                        <Left>
                            <Icon name="bluetooth" />
                        </Left>
                        <Body>
                          <Text>Bluetooth</Text>
                        </Body>
                        <Right>
                            <Text>On</Text>
                            <Icon name="arrow-forward" />
                        </Right>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

List Avatar

List Avatars are medium to showcase an image with your list item whose dimension lays between icon and dimension. To create a avatar list, nest Thumbnail component within ListItem component.

Syntax
import React, { Component } from 'react-native';
import { Container, Content, Left, Body, Right, ListItem, Thumbnail, Text } from 'native-base';
​
export default class ListAvatarExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem avatar>
                        <Left>
                            <Thumbnail source={require('./img/one.png')} />
                        </Left>
                        <Body>
                            <Text>Kumar Pratik</Text>
                            <Text note>Doing what you like will always keep you happy . .</Text>
                        </Body>
                        <Right>
                            <Text note>3:43 pm</Text>
                        </Right>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

List Thumbnail

List Thumbnails are a medium to exhibit an image with your list item. To create a thumbnail list, nest Thumbnail component within ListItem component with few props and style.

Syntax
import React, { Component } from 'react-native';
import { Container, Content, Left, Body, Right, ListItem, Thumbnail, Text } from 'native-base';
​
export default class ListThumbnailExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem thumbnail>
                        <Left>
                            <Thumbnail square size={80} source={require('./img/one.png')} />
                        </Left>
                        <Body>
                            <Text>Sankhadeep</Text>
                            <Text note>Its time to build a difference . .</Text>
                        </Body>
                        <Right>
                            <Button transparent>
                                <Text>View</Text>
                            </Button>
                        </Right>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

Dynamic List

A center aspect designed for efficient representation of vertically scrolling lists of changing data. The simplest way is to create a List dataArray, populate it with an easy array of data chunks, and instantiate a ListItem component with that chunk of data and a renderRow callback which takes a chunk from the whole data array and returns a renderable component.

Syntax
import React, { Component } from 'react';
import { Container, Content, List, ListItem, Text } from 'native-base';
​
export default class DynamicListExample extends Component {

    render() {

        var items = ['Simon Mignolet','Nathaniel Clyne','Dejan Lovren','Mama Sakho','Emre Can'];

        return (
            <Container>
                <Content>
                    <List dataArray={items} renderRow={(data) =>
                        <ListItem>
                            <Text>{data}</Text>
                        </ListItem>
                    } />
                </Content>
            </Container>
        );
    }
}

For more advanced implementation of rendering list dynamically, take a look at nativebase-tutorial.


Seperator

Seperator component is a separator usually used in list, which can be used for grouping list items. To create a seperator between list of items. Though it is used with List, You can use it anywhere in your app.

Syntax
import React, { Component } from 'react';
import { Container, Content, ListItem, Text, Separator } from 'native-base';
​
export default class SeparatorExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Separator bordered>
                        <Text>FORWARD</Text>
                    </Separator>

                    <ListItem >
                        <Text>Aaron Bennet</Text>
                    </ListItem>
                    <ListItem>
                        <Text>Claire Barclay</Text>
                    </ListItem>
                    <ListItem last>
                        <Text>Kelso Brittany</Text>
                    </ListItem>

                    <Separator bordered>
                        <Text>MIDFIELD</Text>
                    </Separator>

                    <ListItem>
                        <Text>Caroline Aaron</Text>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
bordered - - adds border to the bottom and top of the separator


Picker

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

Syntax
import React, { Component } from 'react';
import { Container, Content, Picker } from 'native-base';

const Item = Picker.Item;​
export default class PickerExample extends Component {

    constructor(props) {
        super(props);
        this.state = {
            selectedItem: undefined,
            selected1: 'key1',
            results: {
                items: []
            }
        }
    }
    onValueChange (value: string) {
        this.setState({
            selected1 : value
        });
    }

    render() {
        return (
            <Container>
                <Content>
                    <Picker
                        iosHeader="Select one"
                        mode="dropdown"
                        selectedValue={this.state.selected1}
                        onValueChange={this.onValueChange.bind(this)}>
                        <Item label="Wallet" value="key0" />
                        <Item label="ATM Card" value="key1" />
                        <Item label="Debit Card" value="key2" />
                        <Item label="Credit Card" value="key3" />
                        <Item label="Net Banking" value="key4" />
                   </Picker>
                </Content>
            </Container>
        );
    }
}



Segment

Segments are best used as an alternative for tabs. Mainly used in iOS.

Syntax
import React, { Component } from 'react';
import { Container, Content, Segment, Left, Right, Segment, Button, Icon } from 'native-base';
​
export default class ProgressBarExample extends Component {
    render() {
        return (
        <Container>
            <Header>
                <Left>
                    <Button transparent>
                        <Icon name="arrow-back" />
                    </Button>
                </Left>
                <Body>
                    <Segment>
                        <Button first><Text>Puppies</Text></Button>
                        <Button last active><Text>Cubs</Text></Button>
                    </Segment>
                </Body>
                <Right>
                    <Button transparent>
                        <Icon name="search" />
                    </Button>
                </Right>
            </Header>
            <Content padder>
                <Text>Awesome segment</Text>
            </Content>
        </Container>
        );
    }
}

Configuration
Segment takes Button as children. The active Button shoud be given an active prop (implementation is totally up to you).
Also the first and last buttons should be given props first and last respectively.
Pro tip: It is advisable to use hasSegment prop with Header if you're using Segment below the header.
Syntax(outside header)
import React, { Component } from 'react';
    import { Container, Content, Segment, Left, Right, Title, Segment, Button, Icon } from 'native-base';
    ​
    export default class ProgressBarExample extends Component {
        render() {
            return (
            <Container>
                <Header hasTabs>
                    <Left>
                        <Button transparent>
                            <Icon name="arrow-back" />
                        </Button>
                    </Left>
                    <Body>
                        <Title>Hello</Title>
                    </Body>
                    <Right>
                        <Button transparent>
                            <Icon name="search" />
                        </Button>
                    </Right>
                </Header>
                <Segment>
                    <Button first><Text>Puppies</Text></Button>
                    <Button><Text>Kittens</Text></Button>
                    <Button last active><Text>Cubs</Text></Button>
                </Segment>
                <Content padder>
                    <Text>Awesome segment</Text>
                </Content>
            </Container>
            );
        }
    }


Radio Button

Radio buttons let the user select any one from a set of options.
Replacing Component: React Native <TouchableOpacity>

Syntax
import React, { Component } from 'react';
import { Container, Content, ListItem, Text, Radio, Right } from 'native-base';
​
export default class RadioButtonExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <ListItem selected={false}>
                        <Text>Lunch Break</Text>
                        <Right>
                          <Radio selected={false} />
                        </Right>
                    </ListItem>
                    <ListItem selected={true}>
                        <Text>Discussion with Client</Text>
                        <Right>
                            <Radio selected={true} />
                        </Right>
                    </ListItem>
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
selected false true
false
Represents the state value of an item from set of choices.



Spinner

If you have certain screens of your app that take some time to load, you may want to consider a page loader. A page loader is any kind of animation that visually communicates to a visitor that the page is loading and to just sit tight for a few seconds. Without a page loader, user might think that the app is being unresponsive and just click away in frustration. A page loader also provides a small distraction which can actually makes the wait seem much shorter.
Replacing Component: React Native <ActivityIndicator>

Syntax
import React, { Component } from 'react';
import { Container, Content, Spinner } from 'native-base';
​
export default class SpinnerExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Spinner />
                    <Spinner color='red' />
                    <Spinner color='green' />
                    <Spinner color='blue' />
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
color #45D56E user-defined Color of Spinner.


Tabs

Tabs are a horizontal region of buttons or links that allow for a consistent navigation experience between screens. It can contain any combination of text and icons, and is a popular method for enabling mobile navigation.

Syntax(simple)
import React, { Component } from 'react';
import { Container, Content, Tab, Tabs } from 'native-base';

import Tab1 from './tabOne';
import Tab2 from './tabTwo';
​
export default class TabsExample extends Component {
    render() {
        return (
            <Container>
            <Header hasTabs />
            <Tabs>
                <Tab heading="Tab1">
                    <Tab1 />
                </Tab>
                <Tab heading="Tab2">
                    <Tab2 />
                </Tab>
                <Tab heading="Tab3">
                    <Tab3 />
                </Tab>
            </Tabs>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
locked false true
false
Disable swipe
initialPage - integer Set default active tab

Syntax(advanced)
import React, { Component } from 'react';
import { Container, Content, Tab, Tabs, TabHeading, Icon, Text } from 'native-base';

import Tab1 from './tabOne';
import Tab2 from './tabTwo';
​
export default class TabsExample extends Component {
    render() {
        return (
            <Container>
            <Header hasTabs/>
            <Tabs>
                <Tab heading={ <TabHeading><Icon name="camera" /><Text>Camera</Text></TabHeading>}>
                    <Tab1 />
                </Tab>
                <Tab heading={ <TabHeading><Text>No Icon</Text></TabHeading>}>
                    <Tab2 />
                </Tab>
                <Tab heading={ <TabHeading><Icon name="apps" /></TabHeading>}>
                    <Tab3 />
                </Tab>
            </Tabs>
            </Container>
        );
    }
}

Syntax(scrollable)
import React, { Component } from 'react';
import { Container, Content, Tab, Tabs, Icon, Text, ScrollableTab } from 'native-base';

import Tab1 from './tabOne';
import Tab2 from './tabTwo';
​
export default class TabsExample extends Component {
render() {
    return (
        <Container>
        <Header hasTabs/>
        <Tabs renderTabBar={()=> <ScrollableTab />}
          <Tab heading="Tab1">
              <Tab1 />
          </Tab>
          <Tab heading="Tab2">
              <Tab2 />
          </Tab>
          <Tab heading="Tab3">
              <Tab3 />
          </Tab>
          <Tab heading="Tab4">
              <Tab4 />
          </Tab>
          <Tab heading="Tab5">
              <Tab5 />
          </Tab>
        </Tabs>
        </Container>
    );
}
}

TabHeading Configuration
Property Default Option Description
heading - string, <TabHeading/> Label String, or Compnoent
tabStyle - style object Style for tabbar
activeTabStyle - style object Style for active tabbar
textStyle - style object Style for text
activeTextStyle - style object Style for active text

Pro tip: It is advisable to use hasTabs prop with Header while using Tabs.
Known issues: Custom tabHeading is not yet supported for ScrollableTab. heading only accepts a string.

Thumbnail

Thumbnail component works very similar to Image. It helps you to showcase an image with variuos dimensions and shapes. By default, Thumbnail renders an image in circular shape.
Replacing Component: React Native <Image>

Syntax
import React, { Component } from 'react';
import { Container, Content, Thumbnail, Text } from 'native-base';
​
export default class ThumbnailExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Text>Square Thumbnail</Text>
                    <Thumbnail square source={require('./img/one.png')} />
                    <Thumbnail style={{width: 80, height: 80}} square source={require('./img/one.png')} />

                    <Text>Circular Thumbnail</Text>
                    <Thumbnail source={require('./img/two.png')} />
                    <Thumbnail style={{width: 80, height: 80, borderRadius: 40}} source={require('./img/two.png')} />
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
source - - Image path for thumbnail.
square - - Represents shape of thumbnail.
By default thumbnail is circle in shape.
small - - Small thumbnail with width and height of 40px.
large - - Large thumbnail with width and height of 80px.


Toast

NativeBase Toast can be used to display quick warning or error messages.

Syntax
import React, { Component } from 'react';
import { Container, Content, Toast, Button, Text, Header, Left, Right, Body, Title } from 'native-base';
​
export default class Toast extends Component {
  constructor(props) {
  super(props);
  this.state = {
    showToast: false
  }
}
render() {

  return (
      <Container>
        <Header>
          <Left>
            <Button transparent>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>Hello</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Button onPress={()=> Toast.show({
              text: 'Wrong password!',
              position: 'bottom',
              buttonText: 'Okay'
            })}>
            <Text>Toast</Text>
          </Button>
        </Content>
      </Container>
  );
}
}

Configuration
Key Value Option Description
text - string The text content to be shown in the toast.
buttonText - string The text to be displayed inside the button.
position bottom top, bottom, center Sets position for the toast.
type - danger, success, warning Sets context to the Toast.
duration - integer Milliseconds after which Toast disappers

Note: For Toast to work, it has to be called inside Container.

Typography

NativeBase provides you with the Heading Tags, namely H1, H2 and H3 components. These Heading tags helps you prioritize the content of your screen.
Replacing Component for H1, H2, H3, Text: React Native <Text>

Syntax
import React, { Component } from 'react';
import { Container, Content, H1, H2, H3, Text } from 'native-base';
​
export default class TypographyExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <H1>Header One</H1>
                    <H2>Header Two</H2>
                    <H3>Header Three</H3>
                    <Text>Default</Text>
                </Content>
            </Container>
        );
    }
}

Configuration
Property Default Option Description
H1 font-size: 27 user-defined Heading tag <H1>
H2 font-size: 24 user-defined Heading tag <H2>
H3 font-size: 21 user-defined Heading tag <H3>


Drawer

Drawer for both iOS and Android
Drawer is used from react-native-drawer <Drawer>

Syntax
import React, { Component } from 'react';
import { Drawer } from 'native-base';
import SideBar from './yourPathToSideBar';
​
export default class DrawerExample extends Component {
    render() {
      closeDrawer = () => {
        this._drawer._root.close()
      };
      openDrawer = () => {
        this._drawer._root.open()
      };
        return (
            <Drawer
              ref={(ref) => { this._drawer = ref; }}
              content={<SideBar navigator={this._navigator} />}
              onClose={() => this.closeDrawer()}
            >
            // Main View
          </Drawer>
        );
    }
}

Note: You need to create your own SideBar component and import it.

Ref to Components

  • NativeBase is built on top of React Native. Hence, the components of NativeBase have respective replacing React Native elements.
  • NativeBase has now made it easy for developers, to access the any of its components using ref, along with its associated React Native elements.
  • After building your component, you may find yourself wanting to reach out and invoke methods on component instances returned from render().
  • This can be achieved from refs. Refs are a great way to send a message to a particular child instance.
  • The ref attribute takes a callback function, and the callback will be executed immediately after the component is mounted or unmounted.
  • All NativeBase components refs can be accessed by adding _.root to the actual ref of the Component.

Syntax
import React, { Component } from 'react';
import { Container, Content, Button, Text } from 'native-base';
​
export default class RefExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button onPress={() => this.refs.secondButton._button.onPress()}>
                        <Text>Click Me</Text>
                    </Button>
                    <Button ref="secondButton">
                        <Text>Submit</Text>
                    </Button>
                </Content>
            </Container>
        );
    }
}

  • _.button gets you the reference of NativeBase Button.
  • _.root gets you the reference of NativeBase Button's replacing React Native element i.e., TouchableOpacity.
  • This feature is accessible with all of NativeBase components.



Keep waiting for more from us . . .