@capacitor/status-bar
The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.
Install
npm install @capacitor/status-bar
npx cap sync
iOS Note
This plugin requires "View controller-based status bar appearance"
(UIViewControllerBasedStatusBarAppearance) set to YES in Info.plist. Read
about Configuring iOS for
help.
The status bar visibility defaults to visible and the style defaults to
Style.Default. You can change these defaults by adding
UIStatusBarHidden and/or UIStatusBarStyle in Info.plist.
setBackgroundColor and setOverlaysWebView are currently not supported on
iOS devices.
Example
import { StatusBar, Style } from '@capacitor/status-bar';
// iOS only
window.addEventListener('statusTap', function () {
console.log('statusbar tapped');
});
// Display content under transparent status bar (Android only)
StatusBar.setOverlaysWebView({ overlay: true });
const setStatusBarStyleDark = async () => {
await StatusBar.setStyle({ style: Style.Dark });
};
const setStatusBarStyleLight = async () => {
await StatusBar.setStyle({ style: Style.Light });
};
const hideStatusBar = async () => {
await StatusBar.hide();
};
const showStatusBar = async () => {
await StatusBar.show();
};
API
setStyle(...)
setStyle(options: StyleOptions) => Promise<void>
Set the current style of the status bar.
| Param | Type |
|---|---|
options | |
Since: 1.0.0
setBackgroundColor(...)
setBackgroundColor(options: BackgroundColorOptions) => Promise<void>
Set the background color of the status bar.
This method is only supported on Android.
| Param | Type |
|---|---|
options | |
Since: 1.0.0
show(...)
show(options?: AnimationOptions | undefined) => Promise<void>
Show the status bar.
| Param | Type |
|---|---|
options | |
Since: 1.0.0
hide(...)
hide(options?: AnimationOptions | undefined) => Promise<void>
Hide the status bar.
| Param | Type |
|---|---|
options | |
Since: 1.0.0
getInfo()
getInfo() => Promise<StatusBarInfo>
Get info about the current state of the status bar.
Returns:
Promise<StatusBarInfo>
Since: 1.0.0
setOverlaysWebView(...)
setOverlaysWebView(options: SetOverlaysWebViewOptions) => Promise<void>
Set whether or not the status bar should overlay the webview to allow usage of the space underneath it.
This method is only supported on Android.
| Param | Type |
|---|---|
options | |
Since: 1.0.0