Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 2.04 KB

SetUp.md

File metadata and controls

42 lines (36 loc) · 2.04 KB

Theming NativeBase Apps

Customizing NativeBase will be a cakewalk for you. That is due to the fact, NativeBase has categorized its screens into different sections. It provides a separate file inclusive of color schemes for different sections.

Note: NativeBase is built on top of React Native.
Hence with any component you can pass the style property which will be merged to the default style of that component.

Steps to be followed to customize NativeBase theme:

  • Copy the file light.js (/node_modules/native-base/Components/Themes/light.js)
  • Create a folder Themes under your rootProject and paste the file here.
    Say myTheme.js
  • Import the file Themes/myTheme.js into your code.
    Make the necessary theme changes into myTheme.js.
  • Include prop theme with the component whose theme you wish to change.

Now your project is ready for theme customization.

General Syntax

import {Container, Content, Text} from 'native-base';
import React, {Component} from 'react-native';
import myTheme from './Themes/myTheme';
​
export default class ThemeExample extends Component {
    render() {
        return (
            <Container>
                <Content theme={myTheme}>
                    <Text>
                        I have changed the text color.
                    </Text>
                </Content>
            </Container>
        );
    }
}
  • The theme prop can be applied to any component of NativeBase.
  • The theme holds good with all its descendants.
  • The above code for theme change works this way:
    Go to Themes/myTheme.js and modify color code for textColor.
  • Similarly you can customize theme for the rest of NativeBase components by modifying color code of their respective attributes, some of which are explained below.