I feel like utility classes had their moment and we can now start to pull back towards semantic CSS with the help of new features like CSS custom properties.
Instead of .f-green in your HTML you can do --f-green in your CSS.
<header class="f-green"></header>
would become
header {
color: var(--f-green);
}
or if you really hate CSS and must stay in HTML
<header style="var(--f-green)"></header>
Though the literal naming is a touch too specific anyway. Something like this is wonderful:
--f1-color: green;
header {
color: var(--f1-color);
}
then you don't have to do confusing things like
header .f-green {
color: red;
}
because you can do
header {
--f1-color: red;
}
So we can be less specific AND more modular... because you can have that f1 (font1) color be red in your header, and still do:
footer {
--f1-color: green;
}
We can make really flexible and extensible systems with modern vanilla CSS. No frameworks or preprocessors needed.
This was the only bit in tailwind we modified a lot in our Config. You really need to remove the default colors and define them as [Primary, Secondary, Neutral, Warning, Error, Success] and then add variants of each. Then it really works. I honestly think this should be a default config change/setup option in TW. Nobody with a Design System/Brand guidelines should be including the default colors in their app.
I used to think this way, but 1) it’s easy to do a find replace of f-green and 2) turns out no one we work with changes websites this way. The closest I’ve seen is changing a font site wide with some size etc adjustments
Yep, Tailwind didn't invent style tokens or composable classes! After learning Foundation, Tachyons, Material UI, Chakra...I was happy to see we finally settled on Bootstrap.
Oh, we didn't? Well, time to learn a new syntax. (Was it `dark:md:hover:text-slate-400` or `hover:md:dark:text-slate-400` again?) At least Tailwind arguably has more benefits than its predecessors.
I think Tachyons struck the balance to be honest. Tailwind's "functions" and combinations seem to allow a higher level of complexity where it becomes difficult to quickly inspect a class block after some time has passed.
I will always argue against this. Keep your layout in one file and your styling in another. I've done more CSS than most in heavy web production and I never once had a reason to think something like this would be faster or more efficient.
CSS Utility classes are "faster" and that is the draw, but once they have been overused and abused, then you are either stuck with them, or you spend a lot of time cleaning the tech debt and rewriting the css properly.
At my current job, I work on a legacy application which is still actively developed and released. I spend a lot of my time cleaning up inline styles, styles that are applied via javascript calls, and style blocks on individual pages. I wish the inline styles would have been utility classes, because at least then they would be easy to find and replace, instead, there are "margin-top: 3px" and "margin: 4px 0 0" and "padding-top: 2px" and dozens of variations on that that had they just done something like ".mt-small { margin-top: 3px }" there wouldn't be so many variations and inconsistent looking pages. This company would have benefited greatly from Bootstrap or Tailwinds. I hate both of those, but there is no denying how easy they are to use and abuse.
CSS is one of the places in web dev that never really reached consensus, even today. We might get WASM as the app platform of the web before this even happens.
While I don't really like it myself, Tailwind is a good CSS framework for the age of component-based application design, where your JS / CSS / HTML lives in a single file, and your application-design won't change that heavily.
But when you want to redesign a whole site after the fact, or if you want to keep your component library logic & templates, and port it to a new system, Tailwind might be more trouble than it's worth.
It's just that... Atomic CSS has its benefits, BEM has its benefits, etc etc etc.
Why do you feel it's nonsense? I'm genuinely curios.
Personally I'm using Tailwind for 90% of the styling. If I keep repeating a certain combination of classes often, I'll group it with a custom class. (Edit: See colejohnson66's comment for an example)
Two advantages of tailwind that I didn't see before I started using it:
- It's often easier to find what I want in the tailwind documentation, and it comes with nice examples. MDN is great, but with Tailwind I get reasonable presets.
- TailwindUI: Saves me a lot of time and looks good without feeling as generic as bootstrap.
micromacrofoot|2 years ago
Instead of .f-green in your HTML you can do --f-green in your CSS.
<header class="f-green"></header>
would become
header { color: var(--f-green); }
or if you really hate CSS and must stay in HTML
<header style="var(--f-green)"></header>
Though the literal naming is a touch too specific anyway. Something like this is wonderful:
--f1-color: green;
header { color: var(--f1-color); }
then you don't have to do confusing things like
header .f-green { color: red; }
because you can do
header { --f1-color: red; }
So we can be less specific AND more modular... because you can have that f1 (font1) color be red in your header, and still do:
footer { --f1-color: green; }
We can make really flexible and extensible systems with modern vanilla CSS. No frameworks or preprocessors needed.
munk-a|2 years ago
Also, if your company rebrands from green to red you can just `.f-green {color:#f00;}` - it's so efficient!
agloe_dreams|2 years ago
xeckr|2 years ago
That way you can define your company's --brand-colour at the top of the file.
interstice|2 years ago
unknown|2 years ago
[deleted]
CodeWriter23|2 years ago
cantSpellSober|2 years ago
Oh, we didn't? Well, time to learn a new syntax. (Was it `dark:md:hover:text-slate-400` or `hover:md:dark:text-slate-400` again?) At least Tailwind arguably has more benefits than its predecessors.
city41|2 years ago
[0]https://acss.io/
jamesmccann|2 years ago
Julesman|2 years ago
jermaustin1|2 years ago
At my current job, I work on a legacy application which is still actively developed and released. I spend a lot of my time cleaning up inline styles, styles that are applied via javascript calls, and style blocks on individual pages. I wish the inline styles would have been utility classes, because at least then they would be easy to find and replace, instead, there are "margin-top: 3px" and "margin: 4px 0 0" and "padding-top: 2px" and dozens of variations on that that had they just done something like ".mt-small { margin-top: 3px }" there wouldn't be so many variations and inconsistent looking pages. This company would have benefited greatly from Bootstrap or Tailwinds. I hate both of those, but there is no denying how easy they are to use and abuse.
stevebmark|2 years ago
city41|2 years ago
tuyiown|2 years ago
unknown|2 years ago
[deleted]
city41|2 years ago
Brajeshwar|2 years ago
munk-a|2 years ago
i0nutzb|2 years ago
threatofrain|2 years ago
matheusmoreira|2 years ago
peebeebee|2 years ago
But when you want to redesign a whole site after the fact, or if you want to keep your component library logic & templates, and port it to a new system, Tailwind might be more trouble than it's worth.
It's just that... Atomic CSS has its benefits, BEM has its benefits, etc etc etc.
unknown|2 years ago
[deleted]
unknown|2 years ago
[deleted]
BasilPH|2 years ago
Personally I'm using Tailwind for 90% of the styling. If I keep repeating a certain combination of classes often, I'll group it with a custom class. (Edit: See colejohnson66's comment for an example)
Two advantages of tailwind that I didn't see before I started using it:
- It's often easier to find what I want in the tailwind documentation, and it comes with nice examples. MDN is great, but with Tailwind I get reasonable presets.
- TailwindUI: Saves me a lot of time and looks good without feeling as generic as bootstrap.
draw_down|2 years ago
[deleted]