Automatically animates view to its new position.
A common way to use NativeBase screen structure is to have all the components within <Container>
General Syntax {% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Container, Header, Title, Content, Footer, FooterTab, Button, Left, Right, Body, Icon, Text } from 'native-base'; export default class AnatomyExample extends Component { render() { return (
<Title>Header</Title> This is Content Section Footer ); } } {%- language name="Vue Native", type="vue" -%} Header Content goes here Footer {%- endcodetabs %}- 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
Headercomponent is very similar to your HTML <head>. So is withFooter. - The
Contentcomponent 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 |
{% codetabs name="React Native", type="js" -%} 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 (
<Title>Header</Title> ); } } {%- language name="Vue Native", type="vue" -%} Header {%- endcodetabs %}- This is a NativeBase component which renders as body element of your screen.
- Each screen can have only one
Contentcomponent 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
Contentwithin their app. - Replacing Component: React Native Keyboard Aware Scroll View's KeyboardAwareScrollView
{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Container, Header, Content, Footer, Text } from 'native-base'; export default class ContentExample extends Component { render() { return (
This is Content Section ); } } {%- language name="Vue Native", type="vue" -%} Content goes here {%- endcodetabs %}| Property | Default | Option | Description |
|---|---|---|---|
| padder | true | boolean | Applies margin at all sides to Content section. Can be used with NativeBase View as well. |
| disableKBDismissScroll | false | boolean | Disables automatic scroll on focus. |
| enableResetScrollToCoords | true | boolean | Lets the user enable or disable automatic resetScrollToCoords. |
- NativeBase component that renders as footer, include your favourite apps for your screen.
- There can be only a single Footer component into your Container.
- To have Footer for your screen, include
Footercomponent withinContainer. - NativeBase gives you flexibility to define your Footer component anywhere in the bounds of Container.
- Footer takes input as: FooterTab.
- The components those are defined within
Footerwill be rendered in the same order that you define them. - Footer provides you with stylesheet.
- User can add custom styles while defining
Footerwithin their app. - Replacing Component: React Native View.
{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Container, Header, Content, Footer, FooterTab, Button, Text } from 'native-base'; export default class FooterExample extends Component { render() { return (
Footer ); } } {%- language name="Vue Native", type="vue" -%} Footer {%- endcodetabs %}
