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
Themesunder your rootProject and paste the file here.
SaymyTheme.js - Import the file Themes/myTheme.js into your code.
Make the necessary theme changes into myTheme.js. - Include prop
themewith 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
themeprop 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 fortextColor. - 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.