Whether an Android or iOS app can switch to dark mode at all is decided when the app is built. Web needs no extra setup, but on Android and iOS one app config key sets which appearances the app supports, and on Android that key only works with one extra package installed. Get either part wrong and the app stays light while the phone is in dark mode.
Key terms
- userInterfaceStyle: the app config property that sets which appearances the app supports,
automatic,lightordark. - expo-system-ui: the Expo package for UI outside the React tree, the root view background color and the user interface style on Android.
- Root view background color: the color behind all of your React views, set with the top-level
backgroundColorkey.
automatic, light or dark
userInterfaceStyle takes three values:
automaticfollows the system appearance and reports every change the user makes.lightrestricts the app to the light theme.darkrestricts the app to the dark theme.
An app with no userInterfaceStyle key defaults to light. The default template's app.json sets automatic, so a project created from it follows the phone from the start.
You can also set the key per platform with android.userInterfaceStyle and ios.userInterfaceStyle. A platform key wins on its own platform, and each platform falls back to the top-level value. Android never reads the ios key, so putting automatic only under ios leaves Android on the top-level value, which is light when the key is missing.
Android needs expo-system-ui
In a development build, Android ignores userInterfaceStyle unless expo-system-ui is installed. When it's missing, the terminal prints:
» android: userInterfaceStyle: Install expo-system-ui in your project to enable this feature.
The warning names Android because prebuild applies the iOS appearance setting even without the package. Install it with npx expo install expo-system-ui. You don't add it to plugins: prebuild always runs the Expo SDK plugins, and once the package is installed, its own config plugin is the one that runs. The default template already lists expo-system-ui in its dependencies.
Installing the package doesn't change a running app. The values it applies can't be set at runtime and need a new app binary, so make a new development build after you change userInterfaceStyle or install the package. With the package installed and no userInterfaceStyle key, Android still stays light, because the package's own default is light.
The plugin also checks the value. Anything other than automatic, light or dark stops it with an assertion, for example expo-system-ui: Invalid userInterfaceStyle: "auto".
The color behind your views
The top-level backgroundColor key is the root view background color: the color behind every React view your app renders. android.backgroundColor and ios.backgroundColor override it on their platform. On iOS, both keys need expo-system-ui installed. Without it, prebuild skips the color and warns Install expo-system-ui to enable this feature.
This key is a color only. A dark backgroundColor paints the root view dark and leaves the app's appearance where userInterfaceStyle put it. The app config below sets both: "userInterfaceStyle": "automatic" lets the app follow the phone, and "backgroundColor" gives the root view a light color, with a different shade on iOS.
The config value only changes with a new build. To change the root view color while the app runs, expo-system-ui exports SystemUI.setBackgroundColorAsync(color), which returns a Promise<void> and accepts null. Call it in the root file, outside your components, as the root layout example does on its first line after the imports:
tsxSystemUI.setBackgroundColorAsync('#f4f1ea');
SystemUI.getBackgroundColorAsync() resolves to the current root view color in hex, or null when none is set.
Code Examples
{
"expo": {
"name": "Trail Notes",
"slug": "trail-notes",
"userInterfaceStyle": "automatic",
"backgroundColor": "#f4f1ea",
"ios": {
"backgroundColor": "#f7f5f0"
},
"plugins": ["expo-router"]
}
}import { Stack } from 'expo-router';
import * as SystemUI from 'expo-system-ui';
SystemUI.setBackgroundColorAsync('#f4f1ea');
export default function RootLayout() {
return <Stack />;
}