What's the order of application of classes?
See original GitHub issueI’m using CSS modules, Is there a guaranteed order of application of CSS classes? In the following example, can I expect the resultant style to always have a green background since .bar
is last? I’m getting inconsistent results in my app. Is there a way to enforce order of application then?
// main.css
.foo { background: red; }
.bar { background: green; }
// main.js
import styles from './main.css';
const style = classNames(styles.foo, styles.bar);
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top Results From Across the Web
How order of classes work in CSS ? - GeeksforGeeks
“The order of the classes in which they would work does not depend upon the order, in which they are written in the...
Read more >In what order are CSS classes applied? - Quora
It apparently depends on the order that CSS is defined in your source files, not the order that the classes are listed in...
Read more >What High School Classes Do Colleges Look for on ...
Are you wondering what high school classes do colleges look for on applications? Learn more about the classes you should take to round...
Read more >A Guide to the Education Section of the Common App
From grades to what courses you took, colleges will want to get a detailed look at how you did in high school. Read...
Read more >Classes (OOP) | Brilliant Math & Science Wiki
A class can define types of operations, or methods, that can be performed on a Car object. For example, the Car class might...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is happening when using classnames with postcss modules.
I have something like this.
If
className
is a string, then it is applied before the css modules with posts are applied, even though I specify thatclassName
should be the last thing applied in the function.UPDATE
After using
classnames
andclsx
for a year now, I believe the reason thatclassName
is applied after the CSS module is due to specificity. The CSS module has higher specificity than theclassName
string passed to thecn()
.Hi there! Have you guys found any solution yet? I’ve just stumbled upon the same issue. Thinking how to prioritize the string classname over CSS module.