Status Bar
The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.
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
StatusBarStyle.Light
. You can change these defaults by adding
UIStatusBarHidden
and or
UIStatusBarStyle
in the
Info.plist
.
setBackgroundColor
and setOverlaysWebView
are currently not supported on iOS devices.
Events
Example
window.addEventListener('statusTap', function () {
console.log('statusbar tapped');
});
import { Plugins, StatusBarStyle } from '@capacitor/core';
const { StatusBar } = Plugins;
export class StatusBarExample {
isStatusBarLight = true;
changeStatusBar() {
StatusBar.setStyle({
style: this.isStatusBarLight ? StatusBarStyle.Dark : StatusBarStyle.Light,
});
this.isStatusBarLight = !this.isStatusBarLight;
StatusBar.setOverlaysWebView({
overlay: true,
});
}
hideStatusBar() {
StatusBar.hide();
}
showStatusBar() {
StatusBar.show();
}
}
API
setStyle(…)
setStyle(options: StatusBarStyleOptions) => Promise<void>
Set the current style of the status bar
setBackgroundColor(…)
setBackgroundColor(options: StatusBarBackgroundColorOptions) => Promise<void>
Set the background color of the status bar
show(…)
show(options?: StatusBarAnimationOptions) => Promise<void>
Show the status bar
hide(…)
hide(options?: StatusBarAnimationOptions) => Promise<void>
Hide the status bar
getInfo()
getInfo() => Promise<StatusBarInfoResult>
Get info about the current state of the status bar
Returns: Promise<StatusBarInfoResult>
setOverlaysWebView(…)
setOverlaysWebView(options: StatusBarOverlaysWebviewOptions) => Promise<void>
Set whether or not the status bar should overlay the webview to allow usage of the space
around a device “notch”
Interfaces
StatusBarStyleOptions
StatusBarBackgroundColorOptions
StatusBarAnimationOptions
Prop |
Type | Description |
animation |
StatusBarAnimation |
iOS only. The type of status bar animation used when showing or hiding. |
StatusBarInfoResult
Prop |
Type |
visible |
boolean |
style |
StatusBarStyle |
color |
string |
overlays |
boolean |
StatusBarOverlaysWebviewOptions
Prop |
Type |
overlay |
boolean |
Enums
StatusBarStyle
Members |
Value | Description |
Dark |
"DARK" |
Light text for dark backgrounds. |
Light |
"LIGHT" |
Dark text for light backgrounds. |
StatusBarAnimation
Members |
Value | Description |
None |
"NONE" |
No animation during show/hide. |
Slide |
"SLIDE" |
Slide animation during show/hide. |
Fade |
"FADE" |
Fade animation during show/hide. |
Previous
<-
Splash Screen
Next
Storage ->
Contribute ->