StatusBar
Component to control the app status bar.
Usage with Navigator
It is possible to have multiple StatusBar
components mounted at the same time. The props will be merged in the order the StatusBar
components were mounted.
Imperative API
For cases where using a component is not ideal, there is also an imperative API exposed as static functions on the component. It is however not recommended to use the static API and the component for the same prop because any value set by the static API will get overridden by the one set by the component in the next render.
Reference
Constants
currentHeight
Android
The height of the status bar, which includes the notch height, if present.
Props
animated
If the transition between status bar property changes should be animated. Supported for backgroundColor
, barStyle
and hidden
properties.
Type | Required | Default |
---|---|---|
boolean | No | false |
backgroundColor
Android
The background color of the status bar.
Type | Required | Default |
---|---|---|
color | No | default system StatusBar background color, or 'black' if not defined |
barStyle
Sets the color of the status bar text.
On Android, this will only have an impact on API versions 23 and above.
Type | Required | Default |
---|---|---|
StatusBarStyle | No | 'default' |
hidden
If the status bar is hidden.
Type | Required | Default |
---|---|---|
boolean | No | false |
networkActivityIndicatorVisible
iOS
If the network activity indicator should be visible.
Type | Required | Default |
---|---|---|
boolean | No | false |
showHideTransition
iOS
The transition effect when showing and hiding the status bar using the hidden
prop.
Type | Required | Default |
---|---|---|
StatusBarAnimation | No | 'fade' |
translucent
Android
If the status bar is translucent. When translucent is set to true
, the app will draw under the status bar. This is useful when using a semi transparent status bar color.
Type | Required | Default |
---|---|---|
boolean | No | false |
Methods
popStackEntry()
Get and remove the last StatusBar entry from the stack.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
entry | any | Yes | Entry returned from pushStackEntry . |
pushStackEntry()
Push a StatusBar entry onto the stack. The return value should be passed to popStackEntry
when complete.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
props | any | Yes | Object containing the StatusBar props to use in the stack entry. |
replaceStackEntry()
Replace an existing StatusBar stack entry with new props.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
entry | any | Yes | Entry returned from pushStackEntry to replace. |
props | any | Yes | Object containing the StatusBar props to use in the replacement stack entry. |
setBackgroundColor()
Android
Set the background color for the status bar.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
color | string | Yes | Background color. |
animated | boolean | No | Animate the style change. |
setBarStyle()
Set the status bar style.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
style | StatusBarStyle | Yes | Status bar style to set. |
animated | boolean | No | Animate the style change. |
setHidden()
Show or hide the status bar.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
hidden | boolean | Yes | Hide the status bar. |
animation iOS | StatusBarAnimation | No | Animation when changing the status bar hidden property. |
setNetworkActivityIndicatorVisible()
iOS
Control the visibility of the network activity indicator.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
visible | boolean | Yes | Show the indicator. |
setTranslucent()
Android
Control the translucency of the status bar.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
translucent | boolean | Yes | Set as translucent. |
Type Definitions
StatusBarAnimation
Status bar animation type for transitions on the iOS.
Type |
---|
enum |
Constants:
Value | Type | Description |
---|---|---|
'fade' | string | Fade animation |
'slide' | string | Slide animation |
'none' | string | No animation |
StatusBarStyle
Status bar style type.
Type |
---|
enum |
Constants:
Value | Type | Description |
---|---|---|
'default' | string | Default status bar style (dark for iOS, light for Android) |
'light-content' | string | Dark background, white texts and icons |
'dark-content' | string | Light background, dark texts and icons (requires API>=23 on Android) |