Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to know that device mode is dark or light? in react native

Tags:

react-native

I want to change the app color by mode of device whether if it is dark or light.

But I don't know how to check that my device is in dark mode or in light mode.

Please advice something.

enter image description here

like image 706
John Ocean Avatar asked Jan 31 '26 00:01

John Ocean


1 Answers

You can do this with the Appearance module, via

import { Appearance } from 'react-native';

const colorScheme = Appearance.getColorScheme();
if (colorScheme === 'dark') {
  // Use dark color scheme
}

You can also check whether the user has changed those settings by adding a listener like such:

static addChangeListener(listener)

Look here for the documentation.

like image 78
Lexpj Avatar answered Feb 01 '26 17:02

Lexpj



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!