Next.js Discord

Discord Forum

Class styles are cloned multiple times when using css modules

Unanswered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Avatar
Southeastern blueberry beeOP
I guess this is made so i can override a class specific style from another module, but it makes development really hard when randomly i have an element change style because i imported a component inside another component, which then overrides again the styling i gave, and it also creates duplication in the classes
Image

11 Replies

Avatar
Southeastern blueberry beeOP
Is there some convention i'm not following or a setting i can enable to disable this multiple import?
?????? what
Image
why aren't style sheets removed when navigating away from a page??
the overridden style comes from the exercise page i visited
Avatar
Clown
The styling shouldn't be getting overriden tho. Modules should work exactly the same way as normal css does
The innermost element would still override the property defined by whatever is above it.
Thats just how css works
Avatar
Southeastern blueberry beeOP
yes and that makes sense since in the component you are in, you expect the latest css import to be the topmost one, but apparently if you visit another page, the styling of the old page is still retained? i don't understand why this should be
or at least that seems what is happening here
Avatar
Clown
I dont seem to be understanding the issue you're facing ig.
If only a part of the page is changing, the parts that are still visible and higher in hierarchy would still remain the same
Avatar
Southeastern blueberry beeOP
look at the css classes applied to that button i highlighted in the video, and also look at the border left of the button being straight, when i navigate to the exercises page (esercizi) and then come back to the previous page, there are more classes applied to that button, and they overridden the previous style of the component, and now the border is rounded