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

1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay