Skip to content

Latest commit

 

History

History
executable file
·
195 lines (175 loc) · 7.25 KB

Anatomy.md

File metadata and controls

executable file
·
195 lines (175 loc) · 7.25 KB

anatomy-headref

Anatomy

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

Preview ios anatomy-headref Preview android anatomy-headref

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>
        );
    }
}

  • NativeBase provides its own frame component, named after <Container>.
  • All the components should be included within the Container.
  • Container takes mainly three components: <Header>, <Content> and <Footer>.
  • Container comes with its predefined stylesheet, with an added advantage of accepting user-defined styles.
  • Usage of Container's Header component is very similar to your HTML <head>. So is with Footer.
  • The Content component of Container is nothing but the body section of your screen.

Configuration

Property Default Option Description
Header - - Renders as Header (navbar) of your screen.
Input values: Button, Title (Text).
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

##Header Anatomy

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='menu' />
                        </Button>
                    </Left>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right />
                </Header>
            </Container>
        );
    }
}

##Content Anatomy

  • This is a NativeBase component which renders as body element of your screen.
  • Each screen can have only one Content component and can be defined anywhere within the Container.
  • Content takes in the whole collection of React Native and NativeBase components.
  • Content provides you with stylesheet.
  • User can add custom styles while defining Content within their app.
  • Replacing Component: ScrollView of react-native.
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>
        );
    }
}

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.

##Footer Anatomy

  • NativeBase component that renders as footer that includes your favourite apps for your screen.
  • There can be only a single Footer component into your Container.
  • To have Footer for your screen, include Footer component within Container.
  • NativeBase gives you flexibility to define your Footer component anywhere in the bounds of Container.
  • Footer takes input as: Left, Body, Right and FooterTab as well.
  • The components those are defined within Footer will be rendered in the same order that you define them.
  • Footer provides you with stylesheet.
  • User can add custom styles while defining Footer within their app.
  • Replacing Component: React Native View.
import React, { Component } from 'react';
import { Container, Footer, Left, Body, Right, Button, Icon, Title } from 'native-base';
​export default class FooterExample extends Component {
    render() {
        return (
            <Container>
                <Footer>
                    <FooterTab>
                        <Button full>
                            <Text>Footer</Text>
                        </Button>
                    </FooterTab>
                </Footer>
            </Container>
        );
    }
}