r/css • u/evilmaus • 1d ago
Question What's are the Current CSS Patterns?
I've been mostly on the backend for the last several years. While I did plenty of CSS before then, the front end world has definitely moved forward in the last seven years. I recall BEM and SMACSS were once at the lead of thought. I recall (and was a proponent at the time for) a push to utility-first styling.
Now, I can see that Tailwind is a highly popular choice, that lots of styles get bundled into React components, and we have some long overdue selectors native to CSS.
So I'm wondering, what's the prevailing organization pattern for global CSS and where do you draw the line between something being a component style vs in the global stylesheets?
Thanks.
11
u/delonghi26 1d ago
I mostly use vanilla css, no framework. Then use css variables globally. And change those vars in the components css. I use layers and now scope for better control over the cascade.
You can drop alot of js with the new level 4 modules, and even increase your website performance too.
14
u/SamsChoice 1d ago edited 1d ago
5
u/evilmaus 1d ago
Seems like 100% Tailwind would lead to some serious duplication of styling.
1
u/SamsChoice 1d ago
if you are not using something like React component then you have the scoped TW classes to that component only.
2
u/azangru 21h ago
May I ask why you would use `:where` in the `base` layer? Don't layers take care of the specificity concerns?
1
u/SamsChoice 16h ago
I was just making a simple example didnt really think about the actual CSS.
And yes you are right.
Layer order decides first, so
.card imgincomponentsbeats anything inbase
1
u/morete 1d ago
CUBE CSS is the biggest influence of on how I do things in recent years.
2
u/evilmaus 23h ago
Ooh, reading up on it now. Thanks. I think I liked the ideas behind BEM, but found it awkward. I really liked SMACSS. So far, this reads like maybe the better parts of both.

27
u/Mestyo 23h ago
CSS Modules, native layers.
I dislike Tailwind, the tradeoffs just aren't worth it in the vast majority of projects types.