Top
Best
New

Posted by mpweiher 1 day ago

Moving away from Tailwind, and learning to structure my CSS(jvns.ca)
506 points | 308 commentspage 5
locallost 19 hours ago|
I wrote my first CSS 20 years ago, and one thing I can say for sure is that it's impossible to really structure your CSS in this way. The structure will break down over time and it will anyway be buggy and you'll be chasing your tail, as long as everything you do is global. It might work if you're a solo developer, but the reality is most projects involve multiple people trying to get things done. As long as a style is global, changing it will break something else. These days I use scoped styles and that's it.

My favorite is when colleague A broke something from colleague B, who fixed it but broke sometimes from me, and I fixed that and broke what colleague A did. The process repeated once more and it landed again on my desk, where I said wait a minute, I've been here already. We were than able to fix all three things at the same time.

So it's difficult to keep track of everything.

firatsarlar 20 hours ago||
A life framework, consensus, that how the man face the thing that they crafting.
moomoo11 6 hours ago||
oh god bikeshedding alert

next thread

NetOpWibby 20 hours ago||
Nature is healing
zamalek 20 hours ago||
What I don't get about tailwind is: why not just use the style attribute at the point?
thiht 18 hours ago||
With Tailwind:

    <button class="bg-blue-600 text-white px-4 py-2 rounded">
With style:

    <button style="background-color: var(--color-blue-600); color: white; padding: 8px 16px; border-radius: 4px; border: none;">
Now more interestingly, Tailwind with hover and focus styles:

    <button class="bg-blue-600 hover:bg-blue-500 active:bg-blue-700
      text-white px-4 py-2 rounded transition-colors
      focus:outline-none focus:ring-2 focus:ring-blue-400">
That’s not possible with the style attribute.

Even more interesting with Tailwind, a div with dark mode and responsive styles:

    <div class="
      bg-white dark:bg-zinc-900
      p-4 md:p-8
      rounded-xl
      shadow-sm dark:shadow-none
      border border-zinc-200 dark:border-zinc-700
    ">
That’s not possible either with the style attribute.

Now your first instinct might be to "that’s unreadable", but keep in mind HOW you actually read and write this code. You’re not actually reading it to understand what it does like you do with iterative code. You see how the browser renders it, and you just adapt the code. Tailwind code is mostly write-only and maintained by viewing what the component looks like. This code doesn’t need to be reusable either, the whole component needs to be. The Tailwind code inside is unique.

akersten 6 hours ago||
> Now your first instinct might be to "that’s unreadable", but keep in mind HOW you actually read and write this code. You’re not actually reading it to understand what it does like you do with iterative code. You see how the browser renders it, and you just adapt the code. Tailwind code is mostly write-only and maintained by viewing what the component looks like. This code doesn’t need to be reusable either, the whole component needs to be. The Tailwind code inside is unique.

I think this helped me finally understand the chasm between tailwind proponents and me. I just don't think I'll ever be part of the "keep painting each room a slightly different shade until it looks right" camp, when there's the "you can buy all the same color paint ahead of time, and even have some left over for the next five rooms you build" option right there.

Yeah, tailwind as write-only code definitely tracks. I guess some people like that. Not my bag though.

thiht 3 hours ago||
> keep painting each room a slightly different shade until it looks right

You’re still not getting it. That’s NOT what Tailwind is, because Tailwind works in a design system way, so when you use text-sm or bg-sky-400, you’re using variables that can be configured to suit your needs and keep a consistent design everywhere. Tailwind defaults and configurability played a huge part in its success.

0x3f 20 hours ago||
It's much more verbose and can't do everything Tailwind can anyway.

E.g. how do you style a child on parent hover with the style attribute?

dudeinjapan 14 hours ago||
The elephant in the room is AI. The frontier LLMs seem to prefer Tailwind by default. And they do a good job with it--likely because coupling style definitions to your HTML document structure is the least overhead way for an LLM to write code. The alternative--reasoning about a platonic ideal CSS structure, mapping the document structure to that an inferring how the layout will look, then juggling all that while making iterative edits--is a lot more "cognitive" work!
kylehotchkiss 15 hours ago||
Author in 6 months:

How I refactored my rats nest of CSS back to tailwind.

raincole 20 hours ago||
I think the (misuse of) so-called "separation of concerns" has been the most harmful thing that happened in web front end development. HTML can CSS are the same kind of concerns: the presentation layer. The idea that HTML is purely semantic and has nothing to do with presentation is just burying the head in the sand.

Separating HTML and CSS into different files is just like separating a bunch of methods/functions into different files, or splitting one monorepo into git submodules. Yeah, it sometimes makes sense, but if you're doing it for the sake of separating things then just stop.

I think the only point of Tailwind is to make front end devs realizing how much separation of concerns is misunderstood and misused as a dogma. Once you realize that you can ditch Tailwind if you like.

xigoi 18 hours ago||
HTML is the content layer. CSS is the presentation layer.
raincole 17 hours ago||
Yes, this is the exact harmful idea that I was talking about. If this were true than there would be no 'reader mode' in browser. Or the reader mode would not modify the html at all.

What you see in reader mode is the content layer. HTML is a part of the presentation layer.

xigoi 15 hours ago||
Are you arguing that things like headers and navbars (which reader mode hides) are part of the presentation layer, not the content layer?
troupo 20 hours ago||
There are different types of separation of concerns :) https://x.com/simonswiss/status/1664736786671869952
Polarity 20 hours ago||
oh is this stupid hype of defining design in html with a random framework finally over? thank god!
thiht 18 hours ago|
Can we stop with this kind of trash opinion? Do you genuinely believe people use Tailwind because they don’t know any better? I understand why many people have a visceral reaction against Tailwind when learning about it for the first time, but when you actually use it, you really can understand why some of the "anti-pattern" stuff you learned about CSS doesn’t really apply with Tailwind.
hit8run 21 hours ago|
Thats why I maintain the successor to tachyons: https://tachyonsneo.com No build pipeline. Resort to CSS when utilites make no sense. No lock in.
keybits 20 hours ago|
Can you clarify how this relates to Tachyons - do all Tachyons features work? Or is it a subset of Tachyons?
hit8run 3 hours ago||
It's just a rebuilt drop-in replacement stylesheet compatible to the built version of tachhyons 4.12 but using css variables (so when you need to write custom css you can use its tokens) and it has support for grid plus a few more modern utilities.

Building an application you use this as your utility layer that gets you 80% and for the rest you use an application specific custom css to write the parts where css is the best.

More comments...