DEV Community

Cover image for Change the CSS styling of any class using dark mode in React or NextJS
Sufian mustafa
Sufian mustafa

Posted on

Change the CSS styling of any class using dark mode in React or NextJS

You can use body.dark-mode to change the CSS styling of any class component just by adding the body.dark-mode before the className. This will allow you to target specific elements within your class component and style them differently in dark mode.

npm i use-dark-mode 
Enter fullscreen mode Exit fullscreen mode

Example:


.YourCustomClss{
  background: blue;
}

body.dark-mode .YourCustomClss {

  background: #333;
}
Enter fullscreen mode Exit fullscreen mode

Complete tutorial here:

https://dev.to/sufian/how-to-implement-use-dark-mode-in-react-or-next-js-a-step-by-step-guide-2ia0

Top comments (0)