Skip to content

Latest commit

 

History

History
205 lines (197 loc) · 6.94 KB

Header.md

File metadata and controls

205 lines (197 loc) · 6.94 KB

##header-def-headref

Header

  • NativeBase component that renders as Header (navbar) for your screen.
  • There can be a single Header component into your Container.
  • To have Header for your screen, include <Header> component within <Container>.
  • Header takes input as: Button and Title (Text)
  • The components those are defined within <Header> will be rendered in the same order that you define them.
  • Header provides you with stylesheet.
  • User can add custom styles while defining <Header> within their app.
  • Replacing Component: React Native <View>

Preview ios header-def-headref Preview android header-def-headref

Syntax

import React, { Component } from 'react';
import { Container, Content, ListItem, Text, CheckBox, Header } from 'native-base';
export default class CheckBoxExample 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
iosBarStyle - 'light-content', 'dark-content' or 'default' Set iOS barStyle
androidStatusBarColor - - Set bakground color for status bar in android
span - true,false Set header size to half the screen size
hasSubtitle - true,false Add subtitle to the Header Component
noShadow - true,false Removes shadow from iOS and elevation from android
searchBar - true,false Add searchBar to header or not
rounded - true,false Make Header searchBar Rounded
hasSegment - true,false Add Segments to Header Component
hasTabs - true,false Add Tabs to Header Component
backgroundColor - string Set background color

Header with only title

import React, { Component } from 'react';
import { Container, Content, ListItem, Text, CheckBox,Header } from 'native-base';
export default class HeaderTitle extends Component {
    render() {
        return (
            <Container>
                <Header>
                    <Left/>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right />
                </Header>
            </Container>
        );
    }
}

Header with Icon and Text Buttons

import React, { Component } from 'react';
import { Container, Content, ListItem, Text, CheckBox,Header } from 'native-base';
export default class HeaderIconText 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

import React, { Component } from 'react';
import { Container, Content, ListItem, Text, CheckBox, Header } from 'native-base';
export default class HeaderTitle 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>
        );
    }
}