Setup NativeBase Provider
NativeBaseProvider is a component that makes the theme available throughout your app. It uses React's Context API. Add NativeBaseProvider to the root of your app and update App.js as follows:
App.js
Add custom theme (Optional)#
If you need to customize the default theme to match your design requirements, you can extend the theme from native-base.
NativeBase 3.0 provides an extendTheme function that deep merges the default theme with your customizations.
Add colorModeManager (Optional)#
If you want to do something with the color modes in your app, you can use colorModeManager Prop of NativeBaseProvider to achieve it.
In the below example we will show how to store the active ColorMode in a async storage, so it can be consistent all around our app.
Add external dependencies (Optional)#
If you want to use Gradient feature in Box, you need to pass linear gradient dependency as a config object in NativeBaseProvider. This dependency can be either from expo-linear-gradient or react-native-linear-gradient
NativeBaseProvider Props#
| Name | Type | Description | Default |
|---|---|---|---|
| initialWindowMetrics | Object | Mock data for frame and insets. Refer this for further information. | - |
| colorModeManager | { get : Function , set : Function } | Manage Color mode in your app | - |
| theme | Object | use custom theme in your app | NativeBase Default Theme |
| config | {dependencies: {}} | To include external dependencies. For example - Linear gradient | - |