News for hackers. Stuff that matters.
Re:Why Tailwind CSS Won by bennyp101 on Wednesday August 16, 2023 @04:47AM (#37144368)
For getting designs up and running quickly, it really is great.

Being able to think "Hmmm, I want a rounded button, with a border and a blue background" and just typing class="rounded border border-blue-600 bg-blue-500" and it's done.

With lots of UI being components now, it doesn't really matter that it is verbose - I actually find that helpful. And even if you want to have a class that you use all over the place, just use @apply and create a custom class that you can use anywhere.

One place it can be hard to use, is if you have a specific design system - then yea at that point you either work with Tailwind and modify the config to match, or you just go with standard CSS - but at that point it probably makes sense.

Re:Why Tailwind CSS Won by xigoi on Wednesday August 16, 2023 @05:37AM (#37144700)
> Being able to think "Hmmm, I want a rounded button, with a border and a blue background"

I rarely think this. It's usually “I want a button that looks like all other buttons on my site”. Vanilla CSS is great for that.

Re:Why Tailwind CSS Won by chipgap98 on Wednesday August 16, 2023 @06:08AM (#37144921)
Tailwind is also great for this. You create components with Tailwind that make this trivial
Re:Why Tailwind CSS Won by fjfuvucucuc on Wednesday August 16, 2023 @06:30AM (#37145053)
"trivial"?

So I still have to componentize my presentation layers to do tailwind "correctly", but instead of writing CSS in readable multiline chunks in a language every developer already knows, I need to use this cryptic one liner in any order that literally nobody can read?

What in the hell is wrong with this industry? Sometimes clever ideas aren't all that clever. Sometimes they're just dumb.

Re:Why Tailwind CSS Won by wildrhythms on Wednesday August 16, 2023 @06:40AM (#37145120)
This might surprise you but most industry web development today is using components powered by a framework, and Tailwind fits in perfectly to the close coupling of styles to components.
Re:Why Tailwind CSS Won by Incipient on Wednesday August 16, 2023 @07:05AM (#37145279)
But in components with scoped styling, you're better off just using css directly. Create a class that has all the styles you want, then use it in the HTML - nicely and cleanly separates css and HTML code.
Re:Why Tailwind CSS Won by zztop44 on Wednesday August 16, 2023 @07:25AM (#37145428)
Why do you want to separate the CSS and HTML? They’re both style info, especially in component design.
Re:Why Tailwind CSS Won by fjfuvucucuc on Wednesday August 16, 2023 @09:42AM (#37146855)
Because they're not both style info? Html is a markup language, it applies semantic structure to your content, CSS styles html.

Classes are a tool for selecting markup to style. Sure, you can create a class for every single CSS rule you write, but just because you can doesn't mean you should.

Re:Why Tailwind CSS Won by Sander_Marechal on Wednesday August 16, 2023 @06:17AM (#37144975)
Then you're just back at regular CSS with extra steps
Re:Why Tailwind CSS Won by jacobr on Wednesday August 16, 2023 @01:23PM (#37150394)
Yes, the biggest drawback of Tailwind is React. Or specifically, relying on components as the mechanism for style composition.
Re:Why Tailwind CSS Won by LtdJorge on Wednesday August 16, 2023 @06:22AM (#37144998)
I assume OP means that for the fist button of the site, as in creating the site from 0.
Re:Why Tailwind CSS Won by xigoi on Wednesday August 16, 2023 @06:28AM (#37145040)
In that case, you just write

    button {
      /* your styles here */
    }
to set a precedent for all your future buttons.
Re:Why Tailwind CSS Won by troupo on Wednesday August 16, 2023 @07:11AM (#37145314)
In that case you end up with fifteen different variations of that button, class names like "button-cta__hero__overlay" and a smattering of !importants to defeat the cascade you can't chase down
Re:Why Tailwind CSS Won by xigoi on Wednesday August 16, 2023 @07:18AM (#37145365)
I've never ended up with something like this.
Re:Why Tailwind CSS Won by withinboredom on Wednesday August 16, 2023 @07:38AM (#37145537)
Work in bigger teams with bespoke css. It will happen ... eventually ... without fail.
Re:Why Tailwind CSS Won by peferron on Wednesday August 16, 2023 @06:27AM (#37145029)
CSS classes are great for that until you need to reuse HTML and/or JS, at which point you're back to square one. People are moving to components because they solve these 3 things at once.
Re:Why Tailwind CSS Won by izoow on Wednesday August 16, 2023 @06:30AM (#37145054)
> Being able to think "Hmmm, I want a rounded button, with a border and a blue background" and just typing class="rounded border border-blue-600 bg-blue-500" and it's done.

I'm not a frontend developer and don't really know much about these frameworks, but how is this different from just using style="actual css"? This just feels like inline styles reinvented for whatever reason.

Re:Why Tailwind CSS Won by wildrhythms on Wednesday August 16, 2023 @06:38AM (#37145105)
Yes it's like inline styling, but the difference is that with Tailwind your build has just 1 CSS class with { display: flex; } used across your HTML, rather than inline styling or decoupled stylesheets with hundreds of instances of {display: flex}. If you use a framework like React, Angular, Svelte, it makes sense because your styles are usually coupled to your components anyway.
Re:Why Tailwind CSS Won by strken on Wednesday August 16, 2023 @07:09AM (#37145305)
There is a real though very niche reason why having fewer selectors is useful, speaking as someone who has run into the selector limit in IE before.
Re:Why Tailwind CSS Won by martyfmelb on Wednesday August 16, 2023 @07:44AM (#37145587)
Also speaking from experience — you have to have a lot of bespoke CSS and virtually no design system / internal consistency to run into that limit (a.k.a the Movember 2013 brand refresh).

And finally, when you did run into the IE selector limit, you could just split the style sheet in two (fairly trivial if you were using Sass), because the selector limit was per stylesheet.

Re:Why Tailwind CSS Won by pcthrowaway on Wednesday August 16, 2023 @07:04AM (#37145273)
the style attribute doesn't have the full power of stylesheets (and thus tailwind).

media queries and pseudo-elements are impossible, just off the top of my head.

Tailwind's patterns for device responsiveness are actually the most intuitive I've tried

Re:Why Tailwind CSS Won by jmull on Wednesday August 16, 2023 @07:04AM (#37145276)
With inline styles you can’t do media queries (e.g., so your site can look good on both phones and desktops) or pseudo selectors (e.g. :hover).

Also, though it’s lower-level than something like bootstrap, it does have a design system. Bootstrap is like building a model from a kit, plain css is like building a model from scratch, and tailwindcss is like building a model from lego.

Re:Why Tailwind CSS Won by deprecative on Wednesday August 16, 2023 @07:32AM (#37145484)
It's exactly the same but denser. There's no benefit that Tailwind brings that you can't get from writing your own cleaner CSS files. It's like a cult.
Re:Why Tailwind CSS Won by jonwinstanley on Wednesday August 16, 2023 @08:25AM (#37145987)
Yes, the only thing it does is makes writing styles slightly faster and stops you having to name every different component
Re:Why Tailwind CSS Won by deprecative on Wednesday August 16, 2023 @09:17PM (#37155960)
Styles? Doubtful. Naming components? We have to do that anyway with how JavaScript/TypeScript frameworks work these days. Tailwind is a different way of doing it that introduces unnecessary abstractions. To me, that makes it worse than writing vanilla CSS. With CSS you don't have additional dependencies and build processes. It's just CSS.
Re:Why Tailwind CSS Won by bennyp101 on Wednesday August 16, 2023 @09:10AM (#37146531)
For me, when I'm working on a layout (I'm not a designer at all) it's quicker for me to parse words that describe what I want, than to type out

style="border-radius: 5px; border: 1px solid #2563eb; background-color: #3b82f6"

Personal choice obviously, but I work with frameworks and components if I'm doing frontend stuff, so having things as a single name for something that is consistent across everywhere I use it makes it easier for me.

It's not for everyone, and that's cool.