The clock and icons in the status bar sit on top of your screen, and their color has to stand out against whatever header is behind them. expo-status-bar sets that text color, hides and shows the bar, and animates those changes, from JSX, from event handlers, or at build time for the moment the app launches. Its StatusBar component is built on React Native's StatusBar, with defaults that suit Expo apps.
Key terms
- StatusBar: the component exported by
expo-status-barthat sets the status bar's text color and visibility from JSX. - style: the
StatusBarprop for the text color, one ofauto,inverted,lightordark. - StatusBar.setStyle: a static method that sets the text color from code, alongside
StatusBar.setHiddenfor visibility.
Light text, dark text
light means light text, for a dark background. dark means dark text. auto, the default, decides from the active color scheme: dark text when the scheme is light, light text otherwise. inverted does the opposite of auto.
auto looks only at the color scheme. On a profile screen with a dark header, a phone in light mode still gets dark text, which is hard to read against the header. Mount a StatusBar with style="light" in that screen, as the profile example does:
tsx<StatusBar style="light" />
The same component takes hidden to hide the bar and animated to animate changes to style and hidden. On iOS, hideTransitionAnimation picks how the bar appears and disappears with hidden, and defaults to 'fade'.
More than one StatusBar
You will usually have several StatusBar components mounted at once, for example one in the root layout and one in each screen that needs something different. Their props are merged in the order the components were mounted. That lets the root layout set the general case while the profile screen, mounted later, sets light for itself.
Changing it from an event handler
Some changes happen in response to the user, such as a photo viewer that hides the bar when the user taps the image. For those, call the static methods on the component:
StatusBar.setStyle(style, animated?)sets the text color.StatusBar.setHidden(hidden, animation?)hides or shows the bar.animationis'none','fade'or'slide', and defaults to'none'.
In the photo viewer below, the tap handler toggles the bar with a slide:
tsxStatusBar.setHidden(next, 'slide');
expo-status-bar 56.0.0 moved the named exports setStatusBarStyle and setStatusBarHidden to these static methods. The old exports still work, but they are deprecated and will be removed in a future release, and the system bars guide still links them. Write StatusBar.setStyle and StatusBar.setHidden in new code.
The state at launch
The component and its methods act at runtime. For how the bar looks when the app starts, expo-status-bar has a config plugin that sets properties which can't be set at runtime and need a new app binary to take effect. It takes two options:
hidden: whether the status bar starts hidden,trueorfalse.style: the style the status bar starts with,lightordarkonly.autoandinvertedexist only on the component.
Pass neither and the plugin changes nothing. The app config example below starts a reading app with dark text and the bar visible. After changing the plugin's options, make a new build.
The older androidStatusBar key in app config is deprecated and no longer has any effect: Expo's Android config only prints a warning that points you to the expo-status-bar plugin. Its hidden setting maps to the plugin's hidden, and its barStyle (light-content or dark-content) becomes the plugin's style (light or dark). Its backgroundColor and translucent settings have no equivalent among the plugin's options, so drop them.
On web, there is no API for the system status bar, so expo-status-bar does nothing and doesn't throw.
Code Examples
import { StatusBar } from 'expo-status-bar';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
export default function ProfileScreen() {
return (
<View style={styles.screen}>
<StatusBar style="light" />
<View style={styles.header}>
<Text style={styles.name}>Ana Ruiz</Text>
</View>
<ScrollView contentContainerStyle={styles.body}>
<Text>Recent trails</Text>
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
screen: { flex: 1 },
header: { backgroundColor: '#14213d', height: 220, justifyContent: 'flex-end', padding: 16 },
name: { color: '#ffffff', fontSize: 24, fontWeight: '700' },
body: { padding: 16 },
});import { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { Image } from 'expo-image';
import { Pressable, StyleSheet } from 'react-native';
export default function PhotoViewer({ uri }: { uri: string }) {
const [barHidden, setBarHidden] = useState(false);
const toggleBar = () => {
const next = !barHidden;
StatusBar.setHidden(next, 'slide');
setBarHidden(next);
};
return (
<Pressable style={styles.screen} onPress={toggleBar}>
<Image source={{ uri }} style={styles.photo} contentFit="contain" />
</Pressable>
);
}
const styles = StyleSheet.create({
screen: { flex: 1, backgroundColor: '#000000' },
photo: { flex: 1 },
});{
"expo": {
"plugins": [
"expo-router",
[
"expo-status-bar",
{
"hidden": false,
"style": "dark"
}
]
]
}
}