You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Class name prop not overriding component styles #386
Edit: I've pasted the code for the right component now.
My question is how do I do this:
// Example case; my actual case is a button
// Just easier to show what I want to do in one place
// Since I have nested components
...
<ul className={`
${styles.listDefaults}
${customStyles}
`}>
...
and have customStyles override styles.listDefaults?
I did not. It's a known issue with CSS modules and there is only a workaround, unfortunately, which is to increase the specificity of the class you wish to have priority by repeating it:
Activity
frontend-sensei commentedon Nov 23, 2023
Hi @Konglomneshued !
Did you figured out your issue?
Konglomneshued commentedon Nov 24, 2023
I did not. It's a known issue with CSS modules and there is only a workaround, unfortunately, which is to increase the specificity of the class you wish to have priority by repeating it:
frontend-sensei commentedon Nov 24, 2023
Ohh, I see. Unfortunately, I took the same solution.
Thanks for reply.
receter commentedon Apr 17, 2024
Hi I just wrote an article about this exact topic, maybe it helps you understand the issue in more depth: https://dev.to/receter/avoiding-css-order-of-appearance-problems-with-css-modules-3j7p
Cheers!