kadiraydinli/react-native-system-navigation-bar
概要
Android system bars and iOS home indicator for React Native.
Web・アプリ開発計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルreact-native-system-navigation-bar
Control the system bars from React Native: hide or show the navigation and status bars, enter immersive modes, style bar icons, set bar colors, and manage edge-to-edge rendering on Android — with home indicator control on iOS.
Platform support
Android is the primary platform: every API in this library is implemented there, and the Android methods are silent no-ops on iOS. iOS gets two dedicated methods of its own — setHomeIndicatorAutoHidden and setSystemGesturesDeferred — which are silent no-ops on Android. The window insets APIs — getWindowInsets and addWindowInsetsListener — report real values on Android and zeros on iOS, where react-native-safe-area-context remains the right tool. No method requires a platform check before calling.
Version 3 supports the New Architecture only and requires React Native 0.76 or newer. It is implemented as a TurboModule. If your app still runs the old architecture, stay on v2.8.0.
Installation
npm install react-native-system-navigation-bar
# or
yarn add react-native-system-navigation-bar
No extra native setup is required. Rebuild your app after installing.
Requirements: React Native 0.76 or newer with the New Architecture (the default since 0.76). The package declares react-native >= 0.76.0 as a peer dependency, so npm/yarn will warn you at install time if your project is below that.
On an older React Native or the legacy architecture? Stay on the v2 line — it remains available and unchanged:
npm install [email protected]
The v2 documentation is on the v2.8.0 tag.
Quick start
import SystemNavigationBar from 'react-native-system-navigation-bar';
// Hide the navigation bar (swipe from the edge to bring it back)
SystemNavigationBar.hide();
// Full-screen video player: hide everything, bars come back briefly on swipe
SystemNavigationBar.setImmersive('sticky');
// Match the bars to your theme
SystemNavigationBar.setBarColor('#0F172A', { style: 'light' });
// iOS: game-style full screen — the first bottom swipe won't background the app
SystemNavigationBar.setSystemGesturesDeferred();
API
All methods are available on the default export and return a Promise, except addWindowInsetsListener, which returns a subscription.
hide(bar?)
hide(bar?: 'navigation' | 'status' | 'both'): Promise<void>
Hides the given system bar(s). Defaults to 'navigation'. The user brings the bars back by swiping from the corresponding edge, and they stay visible; a tap does not reveal them. hide and show reset the reveal behavior to the platform default, which also ends an immersive mode entered with setImmersive. Android only — for the iOS home indicator, use setHomeIndicatorAutoHidden. See WindowInsetsControllerCompat.hide.
SystemNavigationBar.hide(); // navigation bar only
SystemNavigationBar.hide('status'); // status bar only
SystemNavigationBar.hide('both'); // full screen

show(bar?)
show(bar?: 'navigation' | 'status' | 'both'): Promise<void>
Shows the given system bar(s) again. Defaults to 'navigation'. Like hide, it resets the reveal behavior to the platform default. Android only. See WindowInsetsControllerCompat.show.
SystemNavigationBar.show();
SystemNavigationBar.show('both');
setImmersive(mode, enabled?)
setImmersive(mode: 'lean-back' | 'immersive' | 'sticky', enabled?: boolean): Promise<void>
Enters (or exits, when enabled is false) one of Android's immersive full-screen modes. enabled defaults to true. Android only — for the equivalent game-style behavior on iOS, use setSystemGesturesDeferred.
| Mode | Behavior on Android |
|---|---|
'lean-back' |
Bars reappear when the user taps anywhere on the screen. Suited to passive experiences such as video playback. Android 12 (API 31) deprecated this behavior, and devices running it reveal the bars by edge swipe instead. |
'immersive' |
Bars reappear when the user swipes from an edge. Suited to interactive full-screen apps. |
'sticky' |
Bars appear translucently on swipe and hide again automatically. Suited to games and drawing apps. |
See the Android guide on immersive modes for background.
SystemNavigationBar.setImmersive('sticky');
SystemNavigationBar.setImmersive('sticky', false); // exit
| Lean back | Immersive | Sticky |
|---|---|---|
![]() |
![]() |
![]() |
setBarStyle(style, bar?)
setBarStyle(style: 'light' | 'dark', bar?: 'navigation' | 'status' | 'both'): Promise<void>
Sets the icon style of the system bars. 'light' means light (white) icons for dark backgrounds; 'dark' means dark icons for light backgrounds. bar defaults to 'both'. Android only. See setAppearanceLightNavigationBars.
SystemNavigationBar.setBarStyle('dark'); // dark icons on both bars
SystemNavigationBar.setBarStyle('light', 'status'); // light icons on the status bar

setCaptionBarAppearance(options)
setCaptionBarAppearance(options: {
transparentBackground?: boolean;
style?: 'light' | 'dark';
}): Promise<void>
Styles the caption bar — the system header with the minimize, maximize and close buttons above an app window in desktop windowing. transparentBackground: true lets your own content show through; false restores the system background. style works as in setBarStyle, independently of the status and navigation bars. Keys you omit keep their value; an unknown style rejects, a non-boolean transparentBackground is ignored. Android 15 (API 35) and higher — a silent no-op on older versions and on iOS. See APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND and the desktop header recipe.
SystemNavigationBar.setCaptionBarAppearance({ transparentBackground: true, style: 'dark' });
SystemNavigationBar.setCaptionBarAppearance({ transparentBackground: false }); // system header again
styleneeds a transparent background to be visible — with the system background it has no visible effect.- The caption bar only exists in a desktop window, so elsewhere the call has no visible effect. The setting belongs to the window: call it again when the Activity is recreated.

setBarColor(color, options?)
setBarColor(
color: ColorValue,
options?: {
bar?: 'navigation' | 'status' | 'both';
translucent?: boolean;
style?: 'light' | 'dark';
}
): Promise<void>
Sets the background color of the system bars. Accepts any React Native color value ('red', '#FF0000', '#FF0000AA', 'hsla(110, 56%, 49%, 0.5)', …). Numbers are read as 0xRRGGBBAA, so an opaque red is 0xff0000ff. Unsupported values (PlatformColor, DynamicColorIOS, unparsable strings) reject the promise. bar defaults to 'both'. Pass style to set the icon style in the same call. Pass translucent: true for a see-through bar — the platform then draws its own scrim, ignores the color argument for that bar (getBarColor reports it as #00000000) and, by definition of the platform flag, extends your content underneath that bar. Android only. See Window.setNavigationBarColor.
Note: this is a no-op when the OS enforces edge-to-edge — Android 15+ with
targetSdk35 or higher — because the system draws the bars fully transparent and ignores app-set colors. See Android 15+ and edge-to-edge.
PlatformColor and DynamicColorIOS values cannot be resolved to a single color across the bridge; passing one (or an unparsable string) rejects the promise instead of reaching the native side. The same applies to setDividerColor.
SystemNavigationBar.setBarColor('#FF0000');
SystemNavigationBar.setBarColor('#0F172A', { style: 'light' });
SystemNavigationBar.setBarColor('transparent', { bar: 'navigation', translucent: true }); // color ignored

getBarColor()
getBarColor(): Promise<{ status: string; navigation: string }>
Returns the current colors of both bars as hex strings — #RRGGBB when a bar is opaque, #RRGGBBAA when it is not, so translucent and transparent bars stay distinguishable. The values can be passed straight back to setBarColor. On iOS, and when the native module is unavailable, both resolve to #00000000.
const { status, navigation } = await SystemNavigationBar.getBarColor();
// { status: '#757575', navigation: '#FF0000' }
setDividerColor(color)
setDividerColor(color: ColorValue): Promise<void>
Draws a thin divider line of the given color between the navigation bar and the app content. Android 9 (API 28) and higher — a silent no-op on older versions, which have no divider. Ignored under enforced edge-to-edge. See Window.setNavigationBarDividerColor.
SystemNavigationBar.setDividerColor('#CCCCCC');

setContrastEnforced(enabled)
setContrastEnforced(enabled: boolean): Promise<void>
Controls whether the system guarantees enough contrast for bar icons when a fully transparent bar background is requested (typically by drawing a subtle scrim behind them). Android 10 (API 29) and higher — a silent no-op on older versions, which do not enforce contrast. See Window.setNavigationBarContrastEnforced.
SystemNavigationBar.setContrastEnforced(false);
Coloring a bar does not change how content is laid out — except translucent: true, which the platform couples to drawing behind that bar. To draw behind the bars deliberately, call setEdgeToEdge(true).
setEdgeToEdge(enabled)
setEdgeToEdge(enabled: boolean): Promise<void>
Enables or disables edge-to-edge rendering: with true, your app draws behind the system bars and is responsible for handling insets. Android only. On Android 15+ with targetSdk 35+, edge-to-edge is enforced by the OS and cannot be turned off. See the edge-to-edge guide.
SystemNavigationBar.setEdgeToEdge(true);

isEdgeToEdgeEnabled()
isEdgeToEdgeEnabled(): Promise<boolean>
Returns whether edge-to-edge is enforced by the OS (Android 15+ with targetSdk 35+) or was enabled through setEdgeToEdge. Useful for deciding at runtime whether bar color APIs will have any effect. Edge-to-edge that another library or your own native code enabled is not reflected here.
const edgeToEdge = await SystemNavigationBar.isEdgeToEdgeEnabled();
getNavigationMode()
getNavigationMode(): Promise<'gesture' | 'two-button' | 'three-button'>
Returns the device's current system navigation mode. In 'gesture' mode the navigation bar is a thin transparent handle, so coloring it usually makes no visible difference.
const mode = await SystemNavigationBar.getNavigationMode();
getWindowInsets()
type Insets = { top: number; right: number; bottom: number; left: number };
type InsetsRect = { x: number; y: number; width: number; height: number };
type WindowInsetsInfo = {
statusBars: Insets;
navigationBars: Insets;
captionBar: Insets;
tappableElement: Insets;
systemGestures: Insets;
mandatorySystemGestures: Insets;
displayCutout: Insets;
displayCutoutRects: InsetsRect[];
captionBarRects: InsetsRect[];
visible: { statusBars: boolean; navigationBars: boolean; captionBar: boolean };
};
getWindowInsets(): Promise<WindowInsetsInfo>
Returns a snapshot of the current window's insets, one value per Android inset type instead of one combined safe area, in dp relative to the app window. The *Rects arrays locate the cutout and caption buttons; visible tells a hidden bar from a missing one. Types are exported (Insets, InsetsRect, WindowInsetsInfo). Fields and API levels: Window insets: what this adds to safe-area-context.
const insets = await SystemNavigationBar.getWindowInsets();
// insets.tappableElement.bottom → 0 in gesture navigation, the bar height with three buttons
// insets.captionBar.top → the desktop window header height, 0 outside desktop windowing
On Android it rejects with E_NO_ACTIVITY without a current Activity and resolves zeros before the window is attached; on iOS, or without the native module, it resolves zeros, empty rects and false flags.
addWindowInsetsListener(listener)
addWindowInsetsListener(
listener: (insets: WindowInsetsInfo) => void
): { remove: () => void }
Calls listener with a new snapshot whenever the insets change — rotation, folding, navigation mode, bar visibility, the taskbar, or entering, leaving or resizing a desktop window. It is also called once when the library starts watching a window (first subscription, or a new Activity window), so an early listener still gets real values; later listeners are not, so subscribe first, then read the starting value with getWindowInsets(). remove() is safe to call twice. The window is watched only while a listener exists, without replacing insets listeners installed by React Native, other libraries or your native code. Types are exported (WindowInsetsListener, WindowInsetsSubscription).
const subscription = SystemNavigationBar.addWindowInsetsListener((insets) => {
console.log('Tappable bottom inset:', insets.tappableElement.bottom);
});
// later
subscription.remove();
Android only — on iOS the subscription is valid but the listener is never called. A small hook built on the two methods:
import { useEffect, useState } from 'react';
import SystemNavigationBar from 'react-native-system-navigation-bar';
export function useWindowInsets() {
const [insets, setInsets] = useState(null);
useEffect(() => {
let active = true;
const subscription = SystemNavigationBar.addWindowInsetsListener(setInsets);
SystemNavigationBar.getWindowInsets()
.then((value) => active && setInsets((current) => current ?? value))
.catch(() => {});
return () => {
active = false;
subscription.remove();
};
}, []);
return insets; // null until the first value arrives
}
One transition can produce more than one call (folding can report an intermediate state), so treat each snapshot as the latest value.

setHomeIndicatorAutoHidden(enabled?)
setHomeIndicatorAutoHidden(enabled?: boolean): Promise<void>
Requests that iOS auto-hide the home indicator, via prefersHomeIndicatorAutoHidden. Suited to passive, video-player-style experiences. enabled defaults to true; pass false to withdraw the request. iOS only. See iOS and the home indicator for what this does and does not control.
SystemNavigationBar.setHomeIndicatorAutoHidden();
SystemNavigationBar.setHomeIndicatorAutoHidden(false);
setSystemGesturesDeferred(enabled?)
setSystemGesturesDeferred(enabled?: boolean): Promise<void>
Defers the system edge gestures via preferredScreenEdgesDeferringSystemGestures: the first swipe from the bottom edge is delivered to your app and only a second swipe backgrounds it — the "swipe twice to exit" behavior of full-screen games and drawing apps. enabled defaults to true. iOS only.
SystemNavigationBar.setSystemGesturesDeferred();
SystemNavigationBar.setSystemGesturesDeferred(false);
Window insets: what this adds to safe-area-context
react-native-safe-area-context merges the bars, cutout and caption bar into one set of edge insets — keep using it to pad screens. getWindowInsets() adds what one number cannot: where taps are safe, where system gestures win, whether a bar is hidden or absent, and where the cutout and window buttons are.
| Field | Android type | Min API | When it helps |
|---|---|---|---|
statusBars |
statusBars() |
24 | Top padding for a custom header behind the status bar. |
navigationBars |
navigationBars() |
24 | How far the navigation bar, gesture handle or taskbar reaches in. Keep content clear of it. |
captionBar |
captionBar() |
30 | Desktop window header height. Non-zero only in a desktop or freeform window (in practice, Android 15+ desktop windowing). |
tappableElement |
tappableElement() |
29 (approximate below) | How far tap targets must stay from the edges; smaller than navigationBars when taps reach your app (gesture navigation). |
systemGestures |
systemGestures() |
29 (approximate below) | Edges where back and home gestures beat your swipes. Keep drawers, sliders and carousels clear. |
mandatorySystemGestures |
mandatorySystemGestures() |
29 (approximate below) | The part of systemGestures apps cannot opt out of (typically the bottom home gesture). |
displayCutout |
displayCutout() |
28 | How far the camera notch or hole reaches in, on its own. |
displayCutoutRects |
DisplayCutout.getBoundingRects() |
28 | Exact cutout areas, so content can sit beside a camera hole. |
captionBarRects |
WindowInsets.getBoundingRects() |
35 | Areas of the system caption buttons; the rest of the header is free for your UI. |
visible |
WindowInsetsCompat.isVisible() |
24 (approximate below 30; captionBar 30) |
Whether each bar is currently shown, e.g. after hide() or setImmersive(). |
Values are unrounded dp relative to the app window, not the screen (split screen and desktop windows included); captionBarRects don't change when the window moves.
Older API levels. Through API 29, AndroidX approximates bar, gesture and visible values from legacy insets. Below API 29, tappableElement and both gesture types come from the status and navigation bar values (not 0); on API 28 landscape a cutout edge can be counted into them and navigationBars. captionBar is 0 (visible false) below API 30. Rect arrays are empty below API 28, captionBarRects below API 35; on API 28–34 displayCutoutRects can be empty while displayCutout is non-zero (e.g. landscape with the default cutout mode).
Three-button, gesture and taskbar
The numbers depend on how the user navigates — the main reason tappableElement exists:
| Setup | navigationBars.bottom |
tappableElement.bottom |
systemGestures |
|---|---|---|---|
| Phone, three-button navigation | Full bar height | Same as navigationBars.bottom |
Roughly 0 on the left and right |
| Phone, gesture navigation | Height of the gesture handle area | 0 — taps go through to your app |
Left, right and bottom edges non-zero |
| Large screen, three-button navigation with a pinned taskbar | Taskbar height | Taskbar height | Roughly 0 on the left and right |
| Large screen, gesture navigation with a transient taskbar | Changes as the taskbar shows and stashes | Expected to drop to 0 while the taskbar is stashed |
Left, right and bottom edges non-zero |
The transient taskbar row is observed launcher behavior, not a guarantee: lay out from listener values, don't hard-code it.
Desktop windowing header
In desktop windowing every window has a system header, even in immersive mode; on Android 15+ you can draw your own there, like Chrome's tabs. Assuming edge-to-edge (default when targeting Android 15+, or setEdgeToEdge(true); otherwise offset by your root view's position):
- Call
setCaptionBarAppearance({ transparentBackground: true, style })with astylethat keeps the system buttons legible. - Reserve
captionBar.topfor your header, and hide it whenvisible.captionBarisfalse. - Keep your controls out of
captionBarRects, where the system draws its buttons.
The system uses caption-area touches to drag the window; interactive views there (tabs, a search field) receive input only after native code calls View.setSystemGestureExclusionRects(), which this library does not wrap.
Android 15+ and edge-to-edge
Starting with Android 15, apps targeting SDK 35 or higher are displayed edge-to-edge by default and by force (see the Android 15 behavior changes): the system draws the status and navigation bars over your content with transparent backgrounds, and the window color APIs this library wraps (setBarColor, setDividerColor, setContrastEnforced) are ignored by the OS. This is an Android platform decision, not a library limitation.
What to do instead:
- Call
isEdgeToEdgeEnabled()at runtime. If it resolves totrue, skip bar-color logic — the OS will not apply it. - Call
getNavigationMode()to adapt your layout: in'gesture'mode the navigation area is a small floating handle, while'three-button'mode reserves a full-height bar. - Icon styling still works: use
setBarStyleto keep icons legible over your content. - Visibility and immersive APIs (
hide,show,setImmersive) are unaffected and keep working under edge-to-edge.
On devices and targets where edge-to-edge is not enforced, all color APIs behave as documented above.
On Android 10 (API 29) and older, hiding a system bar resizes the window, so your layout reflows as the bar disappears. Calling setEdgeToEdge(true) keeps the layout stable there, at the cost of handling insets yourself.
iOS and the home indicator
iOS has no system navigation bar; what this library controls there is the home indicator (the line at the bottom of the screen) and the bottom-edge system gesture, through two dedicated methods: setHomeIndicatorAutoHidden and setSystemGesturesDeferred. A few things to know so the behavior does not surprise you:
- Hiding is a preference, not a command.
setHomeIndicatorAutoHidden(true)sets prefersHomeIndicatorAutoHidden, and Apple documents that the system takes it into account but makes the final call. There is no API on iOS to force the indicator to stay visible — passingfalseonly withdraws the hide request. - On iOS 26 and later, the system auto-hides the indicator in every app after a moment of inactivity, so
setHomeIndicatorAutoHiddenproduces little visible difference there — the OS is already doing what it requests. Its effect is most noticeable on earlier iOS versions, where the indicator otherwise stays visible while the app is in use. - Hiding the indicator and deferring the bottom-edge gesture are mutually exclusive. When the indicator is auto-hidden, iOS treats the app as a passive experience and performs the home gesture on the first swipe, ignoring the deferral. Enable one or the other:
setHomeIndicatorAutoHiddenfor video-style experiences,setSystemGesturesDeferredfor game-style "swipe twice to exit". Enabling both leaves you with the indicator-hiding behavior. - Test on a physical device. The iOS Simulator does not reproduce these reliably: mouse swipes often bypass gesture deferral, and the indicator's fade behavior differs from hardware.
- The preference is applied to the view controllers on screen when you call it — the window's root and anything presented above it, such as a React Native
Modal. Present a modal after the call and it starts with the system default; call the method again once it is on screen. - Everything else — bar visibility, immersive modes, colors, styles, divider, edge-to-edge — is a silent no-op on iOS; the status bar belongs to React Native's own StatusBar API. The two queries still answer platform truths rather than no-oping:
isEdgeToEdgeEnabled()resolvestruebecause iOS always lays content out under the system UI, andgetBarColor()resolves#00000000for both bars since iOS has no colored system bars. - The window insets APIs are inert on iOS (
getWindowInsets()resolves zeros, insets listeners are never called,setCaptionBarAppearancedoes nothing) — use react-native-safe-area-context for safe areas.
Migrating from v2
v3 is a rewrite as a New Architecture TurboModule with a smaller, more consistent API. The v2 method names still work as deprecated aliases — they log a deprecation warning in development and will be removed in v4 — so you can upgrade first and rename incrementally.
| v2 call | v3 equivalent |
|---|---|
navigationHide() |
hide() |
navigationShow() |
show() |
fullScreen(true) / fullScreen(false) |
hide('both') / show('both') |
leanBack(enabled) |
setImmersive('lean-back', enabled) |
immersive() |
setImmersive('immersive') — v2 had no way to leave this mode; pass false to the new method to exit |
stickyImmersive(enabled) |
setImmersive('sticky', enabled) |
setBarMode(style, bar) |
setBarStyle(style, bar) — with no style, v2 applied dark icons, and the alias keeps that default |
setNavigationColor(color, style, bar) |
setBarColor(color, { bar: 'navigation' }) plus setBarStyle(style, bar) — setBarColor colors both bars by default, while v2 colored only the navigation bar |
setNavigationColor('translucent') |
setBarColor(color, { translucent: true }) |
setNavigationBarDividerColor(color) |
setDividerColor(color) |
setNavigationBarContrastEnforced(enabled) |
setContrastEnforced(enabled) |
setFitsSystemWindows(fits) |
setEdgeToEdge(!fits) |
setNavigationColor('transparent') also laid content out behind the bars |
setBarColor('transparent', …) colors only; add setEdgeToEdge(true) for the layout change |
lowProfile() |
Removed. It has been a no-op on Android 11+ and there is no modern replacement. |
Behavior change: getBarColor() no longer takes a bar argument and always returns an object — { status, navigation } — instead of a single string for 'status'/'navigation'. Passing the old argument logs a deprecation warning in development.
FAQ
Why doesn't setBarColor change anything on my device?
Two common reasons. On Android 15+ with targetSdk 35+, the OS enforces edge-to-edge and ignores app-set bar colors entirely — check with isEdgeToEdgeEnabled(). And in gesture navigation mode the navigation "bar" is just a thin transparent handle over your content, so a color change is barely visible — check with getNavigationMode().
Why does setBarStyle not stick for the status bar?
A React Native <StatusBar barStyle=…> element in your tree re-applies its own style every time it re-renders, which undoes setBarStyle for the status bar. Use one of the two to own the status bar icon style, not both.
Why is my navigation bar color semi-transparent in three-button navigation?
On Android 15+ with targetSdk 35+, the OS owns the bar background. In three-button mode it takes the requested color but composites it as a translucent scrim over your content; with setContrastEnforced(false) it draws nothing at all, and in gesture mode the color is ignored entirely. There is no app-side setting for a fully opaque bar on those versions. On Android 14 and below, colors apply fully opaque as documented.
Why do the bars come back as soon as the user taps the screen?
You are in 'lean-back' mode, where any tap restores the bars by design. Both hide() and setImmersive('sticky') keep the bars hidden through taps — with 'sticky', the bars only peek in on an edge swipe and hide again on their own.
Why do the system bars reappear when I open a React Native Modal?
Modal opens its own native window on Android, and this library configures the window of your main activity — the modal's window is untouched. Use the statusBarTranslucent and navigationBarTranslucent props of Modal itself, or avoid the native modal in full-screen flows.
License
関連プロジェクトを探す
読み込み中…


