2

This is my code:

<div className={styles.name}></div>

After run the app, in inspect element my class changed to this:

style_name__AYkko

How can I stop it?

2
  • 5
    What do you expect {styles.name} to resolve to on render? This is part of CSS modules to scope CSS, add unique identifiers, to avoid clashing with other CSS the in the application. You could always just use className="theClassYouWant" instead of CSS modules. Commented Apr 25, 2022 at 14:05
  • 4
    If you stop it, it will no longer work.. So I wouldn't try to do that. It looks like you're using CSS modules. In order for them to work as intended, they need to have a unique name so they do not interfere with other modules. Commented Apr 25, 2022 at 14:06

2 Answers 2

2

The only way you can do what you want to do is importing your stylesheet inside _app.js to have it globally scoped and avoid using css-modules. At this point you can use your classes inside regular classNames without getting the unique hash on inspected elements

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

Comments

0

You can wrap the class definition in a :global {} block

:global {
    .name {
        // css definitions
    }
}

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.