This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo NavigationBar
A library that provides access to various interactions with the native navigation bar on Android.
expo-navigation-bar enables you to modify and observe the native navigation bar on Android devices. Due to some Android platform restrictions, parts of this API overlap with the expo-status-bar API.
Properties are named after style properties; visibility, position, backgroundColor, borderColor, and so on.
The APIs in this package have no impact when "Gesture Navigation" is enabled on the Android device. There is currently no native Android API to detect if "Gesture Navigation" is enabled or not.
Installation
- npx expo install expo-navigation-barIf you are installing this in an existing React Native app, make sure to install expo in your project.
Configuration in app config
You can configure expo-navigation-bar using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.
Example app.json with config plugin
{ "expo": { "plugins": [ [ "expo-navigation-bar", { "backgroundColor": "#0f172a", "barStyle": "light", "borderColor": "#1f2937", "visibility": "visible", "behavior": "inset-swipe", "position": "relative" } ] ] } }
Configurable properties
| Name | Default | Description |
|---|---|---|
backgroundColor | undefined | Sets the navigation bar background color. Accepts color string supported by React Native. For example, |
barStyle | undefined | Controls whether Android renders light or dark navigation bar buttons. Accepts |
borderColor | undefined | Sets the divider color above the navigation bar. |
visibility | undefined | Determines whether the navigation bar starts visible or hidden. Accepts |
behavior | undefined | Controls how hidden system bars behave when revealed. Accepts |
position | undefined | Sets whether your layout is inset for the navigation bar. Accepts |
legacyVisible | undefined | Legacy equivalent of |
Are you using this library in an existing React Native app?
If you're not using Continuous Native Generation (CNG) or you're using a native android project manually, then you need to add the following configuration to your native project:
-
To apply
backgroundColorto the navigation bar, addnavigationBarColorto android/app/src/main/res/values/colors.xml:<resources> <!-- ... --> <color name="navigationBarColor">#0f172a</color> </resources>Then, apply
android:navigationBarColorto android/app/src/main/res/values/styles.xml:<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <!-- ... --> <item name="android:navigationBarColor">@color/navigationBarColor</item> </style> -
To apply
borderColor,visibility,position, andbehaviorto the navigation bar, addexpo_navigation_bar_border_color,expo_navigation_bar_visibility,expo_navigation_bar_position, andexpo_navigation_bar_behaviorto android/app/src/main/res/values/strings.xml:<resources> <!-- ... --> <!-- For `expo_navigation_bar_border_color`, convert the color string to a 32-bit integer. --> <string name="expo_navigation_bar_border_color" translatable="false">-14735049</string> <string name="expo_navigation_bar_visibility" translatable="false">visible</string> <string name="expo_navigation_bar_position" translatable="false">relative</string> <string name="expo_navigation_bar_behavior" translatable="false">inset-swipe</string> </resources> -
To apply
legacyVisibleto the navigation bar, addexpo_navigation_bar_legacy_visibleto android/app/src/main/res/values/strings.xml:<resources> <!-- ... --> <string name="expo_navigation_bar_legacy_visible" translatable="false">immersive</string> </resources>
API
import * as NavigationBar from 'expo-navigation-bar';
Component
Type: React.Element<NavigationBarProps>
A component that allows you to configure your navigation bar declaratively.
You will likely have multiple NavigationBar components mounted in the same app at the same time.
For example, if you have multiple screens in your app, you may end up using one per screen.
The props of each NavigationBar component will be merged in the order that they were mounted.
NavigationBarStyle • Default: 'auto'Sets the color of the navigation bar buttons. Default value is "auto"
which picks the appropriate value according to the active color scheme,
eg: if your app is dark mode, the style will be "light".
This will have an effect when the following conditions are met:
- The device navigation bar is using buttons.
- The
enforceContrastoption of theexpo-navigation-barplugin is set tofalse.
Due to a bug in the Android 15 emulator this function may have no effect. Try a physical device or an emulator with a different version of Android.
Component Methods
| Parameter | Type | Description |
|---|---|---|
| hidden | boolean | If the navigation bar should be hidden. |
Set the navigation bar's visibility.
voidExample
NavigationBar.setHidden(true);
| Parameter | Type | Description |
|---|---|---|
| style | NavigationBarStyle | The color of the navigation bar buttons. |
Sets the style of the navigation bar.
This will have an effect when the following conditions are met:
- The device navigation bar is using buttons.
- The
enforceContrastoption of theexpo-navigation-barplugin is set tofalse.
Due to a bug in the Android 15 emulator this function may have no effect. Try a physical device or an emulator with a different version of Android.
voidExample
NavigationBar.setStyle("dark");
Hooks
Deprecated: This will be removed in a future release.
React hook that statefully updates with the visibility of the system navigation bar.
NavigationBarVisibility | nullVisibility of the navigation bar, null during async initialization.
Methods
Deprecated: This will be removed in a future release.
Get the navigation bar's visibility.
Promise<NavigationBarVisibility>Navigation bar's current visibility status. Returns hidden on unsupported platforms (iOS, web).
Deprecated: Use
NavigationBar.setStyleinstead. This will be removed in a future release.
| Parameter | Type | Description |
|---|---|---|
| style | NavigationBarStyle | The color of the navigation bar buttons. |
voidDeprecated: Use
NavigationBar.setHiddeninstead. This will be removed in a future release.
| Parameter | Type | Description |
|---|---|---|
| visibility | NavigationBarVisibility | Based on CSS visibility property. |
Set the navigation bar's visibility.
Promise<void>Event Subscriptions
Deprecated: This will be removed in a future release.
| Parameter | Type |
|---|---|
| listener | (event: NavigationBarVisibilityEvent) => void |
Observe changes to the system navigation bar. Due to platform constraints, this callback will also be triggered when the status bar visibility changes.
EventSubscriptionTypes
Literal Type: string
Navigation bar style.
autowill automatically adjust based on the current theme.lighta light navigation bar with dark content.darka dark navigation bar with light content.invertedthe bar colors are inverted in relation to the current theme.
Acceptable values are: 'auto' | 'inverted' | 'light' | 'dark'
Deprecated: This will be removed in a future release.
Literal Type: string
Visibility of the navigation bar.
Acceptable values are: 'visible' | 'hidden'
Deprecated: This will be removed in a future release.
Current system UI visibility state. Due to platform constraints, this will return when the status bar visibility changes as well as the navigation bar.
| Property | Type | Description |
|---|---|---|
| rawVisibility | number | Native Android system UI visibility state, returned from the native Android |
| visibility | NavigationBarVisibility | Current navigation bar visibility. |