Skip to content

Instantly share code, notes, and snippets.

@hirbod
Last active July 30, 2025 19:56
Show Gist options
  • Save hirbod/d6bb5d0fc946a12ba9e3cf01120c604a to your computer and use it in GitHub Desktop.
Save hirbod/d6bb5d0fc946a12ba9e3cf01120c604a to your computer and use it in GitHub Desktop.
Expo Config Plugin to disable forced Dark mode.
// disable forced dark mode to prevent weird color changes
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { createRunOncePlugin, withAndroidStyles, AndroidConfig } = require('expo/config-plugins')
function setForceDarkModeToFalse(styles) {
const newStyles = AndroidConfig.Styles.assignStylesValue(styles, {
add: true,
// ############# FOLLOW IF YOU'RE ON SDK 52 #############
// TODO: AndroidConfig.Styles.getAppThemeGroup() will be available in SDK 52 (or expo/config-plugins 9+), for now I just hardcoded AppTheme
// parent: AndroidConfig.Styles.getAppThemeGroup(),
parent: { name: 'AppTheme' },
name: `android:forceDarkAllowed`,
value: 'false',
})
return newStyles
}
const withDisableForcedDarkModeAndroid = (config) => {
return withAndroidStyles(config, (config) => {
config.modResults = setForceDarkModeToFalse(config.modResults)
return config
})
}
module.exports = createRunOncePlugin(
withDisableForcedDarkModeAndroid,
'disable-forced-dark-mode',
'1.0.0'
)
@artkrv
Copy link

artkrv commented May 21, 2025

Same issues with 53 splash screen. Does any one prevented dark mode for splash screen.

@danielshin
Copy link

Try installing "expo-system-ui" if you haven't, apparently it's required to enable "userInterfaceStyle". https://docs.expo.dev/develop/user-interface/color-themes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment