← Plugins / Status Bar
This Apache Cordova plugin puts the device's native status bar under your control. You can set its background color, switch the text and icons between light and dark styles, hide or show it, and decide whether the web view draws underneath it — so the bar blends seamlessly with your app's header.
Add the plugin to your Cordova project from the command line:
cordova plugin add cordova-plugin-statusbar
The plugin attaches a global StatusBar object. Use its members after deviceready has fired:
| Member | Description |
|---|---|
StatusBar.overlaysWebView(bool) | Controls whether the web view extends underneath the status bar (iOS). |
StatusBar.styleDefault() | Uses dark text — best for light status bar backgrounds. |
StatusBar.styleLightContent() | Uses light text — best for dark status bar backgrounds. |
StatusBar.backgroundColorByName(colorName) | Sets the background by named color, for example "black". |
StatusBar.backgroundColorByHexString(hex) | Sets the background by hex value, for example "#6c4bf6". |
StatusBar.hide() / StatusBar.show() | Hides or shows the status bar. |
StatusBar.isVisible | A Boolean reporting whether the status bar is currently visible. |
You can also configure the starting appearance in config.xml with preferences such as StatusBarBackgroundColor and StatusBarStyle:
<preference name="StatusBarBackgroundColor" value="#6c4bf6" />
<preference name="StatusBarStyle" value="lightcontent" />
Tint the bar to match your app's accent color and switch to light text:
document.addEventListener("deviceready", onReady, false);
function onReady() {
StatusBar.backgroundColorByHexString("#6c4bf6");
StatusBar.styleLightContent();
}
StatusBar methods after deviceready — the object isn't ready before then.styleLightContent so the clock and status icons stay readable.