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

Sufian mustafa @sufian

About: AI-powered Web developer focused on Next.js + Sanity. Here I share how artificial intelligence is transforming development, programming, and technical SEO strategies. Explore more at doitwithai.tools.

Location:
Islamabad, Pakistan
Joined:
Sep 8, 2023

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

Publish Date: Nov 14 '23
1 0

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

Comments 0 total

    Add comment