Package Exports
- @zoontek/react-native-navigation-bar
- @zoontek/react-native-navigation-bar/dist/commonjs/index.js
- @zoontek/react-native-navigation-bar/dist/module/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zoontek/react-native-navigation-bar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@zoontek/react-native-navigation-bar
React Native StatusBar long-lost twin: A component to control your Android app's navigation bar.
Credits
This project has been built and is maintained thanks to the support from Expo.
Installation
$ npm i -S @zoontek/react-native-navigation-bar
# --- or ---
$ yarn add @zoontek/react-native-navigation-bar[!IMPORTANT] This library requires React Native 0.81+ or Expo 54+ with edge-to-edge enabled. To turn it on, set
edgeToEdgeEnabledtotruein your project'sgradle.propertiesfile (this step is not required for Expo, as it is enabled by default).
edgeToEdgeEnabled=true # 👈 set this to trueConsiderations
Transparency
Compared to react-native-edge-to-edge, this library uses React Native StatusBar API and its defaults: the navigation bar is transparent with a light-content bar style. To enforce a contrasting (semi-opaque) button navigation bar, set the enforceNavigationBarContrast option to true.
React Native
Edit your android/app/src/main/res/values/styles.xml file to inherit from one of the provided themes:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- … -->
<!-- enable a contrasting navigation bar background (optional) -->
<item name="enforceNavigationBarContrast">true</item>
</style>
</resources>Expo
Add the library plugin to your app.json configuration file and create a new build 👷:
{
"expo": {
"plugins": [
[
"@zoontek/react-native-navigation-bar",
{ "android": { "enforceNavigationBarContrast": true } }
]
]
}
}API
NavigationBar
A React component to control the Android button navigation bar (with back / home / recents buttons).
[!NOTE] This component has no effect on other platforms or when gesture navigation is used.
import { NavigationBar } from "@zoontek/react-native-navigation-bare";
type NavigationBarStyle = "default" | "light-content" | "dark-content";
type NavigationBarProps = {
barStyle?: NavigationBarStyle; // set the color of the navigation bar content
hidden?: boolean; // hide the navigation bar
};
const App = () => (
<>
<NavigationBar barStyle="light-content" />
{/* … */}
</>
);NavigationBar.pushStackEntry
Push a NavigationBar entry onto the stack. The return value should be passed to popStackEntry when complete.
const entry: NavigationBarProps = NavigationBar.pushStackEntry(
props /*: NavigationBarProps */,
);NavigationBar.popStackEntry
Remove an existing NavigationBar stack entry from the stack.
NavigationBar.popStackEntry(entry /*: NavigationBarProps */);NavigationBar.replaceStackEntry
Replace an existing NavigationBar stack entry with new props.
const entry: NavigationBarProps = NavigationBar.replaceStackEntry(
entry /*: NavigationBarProps */,
props /*: NavigationBarProps */,
);NavigationBar.setStyle
Set the navigation bar style.
NavigationBar.setStyle(style /*: NavigationBarStyle */);NavigationBar.setHidden
Show or hide the navigation bar.
NavigationBar.setHidden(style /*: boolean */);Troubleshooting 🤔
The bar style blinks at app start
Since the navigation bar is set at runtime rather than through themes, you may notice a brief style change at startup. This can be avoided by adding a splash screen.
The bar style behavior is erratic
There's currently an open issue with the Android 15 emulator image regarding the navigation bar style when it is is fully transparent. This issue does not occur on physical devices.