Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dark Mode: useColorScheme() always returns light on Android

I am trying to get Dark Mode to work and it doesn't work on Android. It always returns "light". On iOS it works fine.

import React from 'react';
import { useColorScheme } from "react-native";

export default function App() {
  const theme = useColorScheme();
  alert("your color scheme is: " + theme); // always returns "light" on Android
  return null;
}

I am using Expo SDK 42.

I put "userInterfaceStyle": "automatic" in my app.json but it doesn't make a difference.

like image 229
André Avatar asked Dec 22 '25 00:12

André


1 Answers

I figured it out. It was not enough to just put "userInterfaceStyle": "automatic" in app.json root, I had to define it for iOS and Android individually too:

app.json:

{
  "expo": {
    "userInterfaceStyle": "automatic",
    "ios": {
      "userInterfaceStyle": "automatic"
    },
    "android": {
      "userInterfaceStyle": "automatic"
    }
  }
}
like image 143
André Avatar answered Dec 24 '25 19:12

André



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!