1

I use next js and mycode like below

import styles from "../components/style/dark.module.scss";

export default function ThemeButton() {
  return (
    <div>
      <button id="dark-mode-toggle" className={styles["dark-mode-toggle"]}>
 
      </button>
      <h1 className={styles["title"]}>
       Title
      </h1>
    enter code here
    </div>
  );
}

Here I am creating an CSS module and importing it and using like above and it works fine.

But everytime I need to type className={styles["dark-mode-toggle"]} instead of just typing class="dark-mode-toggle" , I am migrating from plain html code to React and there are 1000's of class like this.

Is there any way to use class="dark-mode-toggle" and make styles work , without using global styles , I want the styles to be imported only when component is used to make my app lightweight.

1
  • 1
    Since it's JSX, it won't work. However in VSCode you can replace all occurances in a file. Commented Aug 28, 2022 at 8:01

1 Answer 1

0

You can use cmd + shift + H in VScode and replace all occurrences in the project.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.