News for hackers. Stuff that matters.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @08:13AM (#35356043)
I'll post one of my previous comments here, hoping to get a discussion going...

> The problem with Tailwind for me is that Mr Wathan misrepresented « Good CSS » in his essay. His examples are BAD CSS, not good CSS. He then sets out to correct a problem with CSS that HE created by writing dirt poor CSS. `.author-bio > div > h2 { color: red } is NOT good CSS. The div part has no reason being there (why would the div change the color of the title ?). After presenting this auto-created problem, he sets out to solve it with BEM, where you need untold numbers of classes for everything. So now, CSS has a naming problem, created to solve a non-existing auto-created CSS problem. And Tailwind now solves this pseudo-problem.

Apart from this, the thing that really bugs me is that every advantage claimed (apart from one) is also non-existing because if you do your CSS right, the same claimed advantages arise in pure CSS. Design tokens ? No need for json, custom properties are all you need. Specificity ? Cascade layers, pseudo-selectors are here for you.

The only "advantage" I see is the possibility of working in one file only rather than a couple of files. And that, for me at least, is not a real advantage but only a justification for being lazy. There's no way the price of all these processes and dependencies complexity are worth the laziness-added value.

Does someone care to "prove" me wrong here ? At least, can someone engage these arguments ?

Looking forward to it!

Re:Tailwind CSS v3.3 by kaba0 on Wednesday March 29, 2023 @08:24AM (#35356191)
The problem is that I’m not convinced that “good CSS” even exists. Even the very idea of separating content and style seems problematic to me, and in my experience it simply doesn’t works for anything more complex than a markdown converted to html.

Add to it that for some weird reason web’s style includes layouting, which imo should be a separate thing entirely, and this is the primary reason why any given CSS has to be specifically created for a given HTML template, and why seemingly benign CSS modifications can move that 3rd step of the checkout page, rendering it completely broken.

Restricting CSS to a subset of only cascading some very basic properties (fonts, colors, default font-size), and letting everything else be managed on a per component basis (where close coupling of style and template absolutely makes sense) and simply layouting those components to form the given design makes much more sense to me (and frankly, it was sort of figured out a few decades ago by several desktop GUI framework..). And while you can write vanilla CSS this way, tailwind just restricts you to this subset — the same way there sure exists some safe subset of C, but you need something like Rust to restrict you to that [1]

[1] I know, this is not really how it works, it’s only for the analogy’s sake

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @08:43AM (#35356410)
Why is the component-based approach to CSS not working here? Am I missing something?
Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @12:00PM (#35359140)
How would you maintain a reasonable "component-based" approach without something like scss? I'm legitimately curious.

Otherwise, you have to take great pains to ensure styles don't conflict or accidentally apply to things they're not intended for. Or you have to use some other framework/tooling to convert your css selectors and markup so that scoping is enforced

Re:Tailwind CSS v3.3 by claytongulick on Wednesday March 29, 2023 @01:38PM (#35360547)
Shadow DOM works well for this if you need true encapsulation.

A blend of shadow and light DOM in web components solves most of the issues I've run into over the years.

It's also easy to scope styles to a custom component in the light dom with:

    my-component .header {...}
I do this a lot in light DOM web components and render the styles with lit-html as part of a template.
Re:Tailwind CSS v3.3 by quechimba on Wednesday March 29, 2023 @02:42PM (#35361426)
There is also the ::part() selector now which is quite useful for selecting things within a shadow. https://shoelace.style/ uses parts for styling individual parts within custom elements.
Re:Tailwind CSS v3.3 by claytongulick on Wednesday March 29, 2023 @09:03PM (#35366308)
In practice, I've found that to be pretty unwieldy and difficult to use.

My general approach is to keep most application level components in the light dom for styling, and only use shadow dom for library-like components, mostly layouts for slotting light dom stuff.

Re:Tailwind CSS v3.3 by mhoad on Wednesday March 29, 2023 @02:12PM (#35361023)
Web Components use of the shadow DOM is designed for this very use case.

I never have to worry about clashes or getting too cute with my naming conventions. You can just use a h1 selector and not think about it.

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @02:25PM (#35361199)
Very interested in learning more about this. Do you know if there are any open source projects I can take a look at?
Re:Tailwind CSS v3.3 by quechimba on Wednesday March 29, 2023 @02:40PM (#35361396)
Here's an experiment I'm working on, where all styles are scoped to components because all static DOM trees become custom elements...

https://github.com/aalin/rdom

Re:Tailwind CSS v3.3 by mhoad on Wednesday March 29, 2023 @02:45PM (#35361464)
This is in some places a little bit specific to Lit but mostly not and walks you through that shift in mental models from start to finish that tends to trip people up a lot coming to Web Components https://youtu.be/Xt7blcyuw5s

FWIW if you are interested in Web Components I would say Lit is hands down the best entry point I’ve come across. Strong recommendation and nullifies most of the common complaints you tend to hear associated with them.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:25PM (#35362029)
Great question.

Simple linting rules can get you lots of mileage here. First and foremost, you ensure that in any component CSS file, ALL selectors begin with a class that mirrors the filename.

It seems to me that this can prevent the vast majority of conflit or spillover occurences. Don't you think?

Legitimately curious here as well!

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @04:31PM (#35363079)
> First and foremost, you ensure that in any component CSS file, ALL selectors begin with a class that mirrors the filename.

But then you're adding a convention that isn't as easy to follow. Maybe you follow it, but what about new people. What about people who make a typo? Are you going to make a VS code plugin that points out if someone mistypes the file-based class in the CSS file?

What if the file is renamed, or moved? Do you then have to go update every selector in the CSS file?

This all seems so much more brittle to me than just using tailwind, and the VS code plugin show you the possible class names you can select from when you start to type something, as well as rules for each of those class names. It also catches (and highlights) contradictory rules, when applied to the same element. You can't do that from the CSS (there's no telling what the declaration will be used for, from the css in isolation), and unless you make your own editor integration, this won't happen when editing markup either.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @05:03PM (#35363599)
What is the convention? Beginning selectors in a file by the filename only? If I understand correctly, then I'd fallback on the linting.

If the file is renamed, then yes, you change the selectors. That's a simple operation. But I think the same goes for any JS framework where you'd create components. If you change "button" for "secondary-button" you'd have to change it in at least a couple of places I guess? Either way, you should limit these kind of operations to a minimum.

And what if I don't want to use VSCode? Maybe there are Tailwind plugins for every text editor...

But more importantly, that's quite easy to include your CSS files in the autocompletion of, for example, Sublime Text. I'd guess it's the same in VSCode. And again, simple linting should prevent much of these problems I think. You can easily lint contradictory rules in a ruleset. Stylelint would be perfect for that.

And if by mistake you have contradicting rules across rulesets, then a quick look at the devtools will tell you where the problem comes from. On a sidenote, the devtools become real difficult to use in a Tailwind-like paradigm.

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @07:18PM (#35365318)
> If you change "button" for "secondary-button" you'd have to change it in at least a couple of places I guess?

I'm not sure I understand this argument. If I rename a component and the file it's in, I get automatic import renames across the codebase without having to do anything myself. And if I didn't, I'd get errors trying to run the code (I'm not sure how you'd configure CSS to do the same thing with unmatched selectors, though I guess you probably could remove them from the output at least with postcss)

> And what if I don't want to use VSCode? Maybe there are Tailwind plugins for every text editor...

You do you, but according to the 2020 state of JS, 86% of JS devs were using VS Code, and 20% vim (which also has tailwind support): https://2020.stateofjs.com/en-US/other-tools/#text_editors

They removed the question so I don't know what current trends are, but Tailwind is at least supporting 90% of possible users with just those 2 (and I haven't looked into support for other IDEs)

> On a sidenote, the devtools become real difficult to use in a Tailwind-like paradigm.

I haven't found this to be the case at all, I'm not sure why Tailwind would make the devtools more difficult. If anything, it makes it easier since I typically only have to look at the CSS section for elements which have inherited styles

Re:Tailwind CSS v3.3 by emmacharp on Thursday March 30, 2023 @05:52AM (#35370261)
A simple find and replace would do the same then for a CSS change. Again, that's not something that should happen often.

As for support in text editors, you can still autocomplete any class you have in your CSS. And the CSS linting will give errors too if you have problems. And there are CLI programs for discovering unmatched CSS, which works pretty well in my experience.

And the devtools suffer from all the added classes. It can slow down to a crawl depending on your machine. And you can't play as easily with the styles... If I disable a property in the cascade, all other items with this property will lose it. I would say it goes against the devtools grain. But I guess it depends on your usage.

Re:Tailwind CSS v3.3 by michaelcampbell on Wednesday March 29, 2023 @12:12PM (#35359289)
I'm far from being even "above average" at CSS, but this approach (as a long time developer, mostly in OO) has made the most sense to me. Little bundles of things in their own contexts that apply to a limited area. I can re-use names as they are appropriate for their contexts and not worry about cross contamination.

But, other people do things differently so maybe it's not the best approach for them; but for my limited needs and experience, it's been fine, if not great.

Re:Tailwind CSS v3.3 by rimliu on Wednesday March 29, 2023 @08:53AM (#35356516)
Separation content and style works perfectly well. Just people never bother to learn neither HTML nor CSS and rely on some generated monstrosity, be it generated by WP or React.
Re:Tailwind CSS v3.3 by michaelcampbell on Wednesday March 29, 2023 @12:14PM (#35359324)
It works for me mostly only theoretically. When I have to apply it at scale I run into the practical problems that people mention here; 1 big namespace, mostly.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:28PM (#35362075)
Do you mean conflicts or spillovers?

Because, as I said elsewhere in the thread, I think (maybe wrongly) that simple linting could rid you of the vast majority of these problems.

But, please, if you mean something else, do comment! I very much like this discussion.

Re:Tailwind CSS v3.3 by michaelcampbell on Thursday March 30, 2023 @08:47AM (#35371797)
For me I meant coming up with a name that semantically describes this area of the HTML, that I haven't already used.
Re:Tailwind CSS v3.3 by emmacharp on Thursday March 30, 2023 @11:19AM (#35374028)
Well, don't you already name component file after it? Maybe I still misunderstand...
Re:Tailwind CSS v3.3 by XCSme on Wednesday March 29, 2023 @10:24AM (#35357736)
> Even the very idea of separating content and style seems problematic to me

When I try to "separate" CSS, I always end up creating utility classes (so kind of like Tailwind).

Currently, I like to use a combination of utility classes (e.g. class="text-bold") and high-level class modifiers (like a ".pricing" wrapper, and then I can modify everything inside the pricing section like spacing, font sizes, colors).

    .pricing h2 { color: var(--color-tertiary); }
I think this makes more sense than adding "color-tertiary" class to each h2, because if I want to change the color, I would have to modify it in all the h2 tags.

I would use "text-bold" if there is a one-time instance where I want the text to be emphasized. If there can be a rule extracted (e.g. make every first word bold), I would use CSS selectors/classes to modify all those instances.

Re:Tailwind CSS v3.3 by ghc on Wednesday March 29, 2023 @08:29AM (#35356250)
Nobody's going to engage with those arguments because they miss the point. Tailwind is CSS, ergo it wouldn't work if what you're saying wasn't possible.

Writing good CSS for interfaces in a web application of significant complexity is expensive and time consuming. Tailwind solves that problem very well. Other CSS frameworks have done so as well over the years -- I wouldn't call Tailwind unique -- but the micro-class approach it takes is perfect for modern interface templating systems like Vue, where you tend to abstract at the component level instead of at the style level.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @08:41AM (#35356386)
How is that better from enclosing CSS in a component file with a class as first selector?

I see that bad developers could make mistakes, but besides that, which is kind of easy to lint, the only advantage I see is the need to maintain only one file instead of two.

What do I get wrong?

Re:Tailwind CSS v3.3 by adamhp on Wednesday March 29, 2023 @09:06AM (#35356677)
It is quite fast to make changes and see immediate visual results. There's basically one less step to making css changes. What you call "lazy" in your OP, the rest of us comfortably call "useful".

If I need to add some padding, I slap on some p-4, my browser refreshes, and I see the result.

I don't really get the spiritual debate. It's a tool, use it or don't.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @09:24AM (#35356931)
You can do the exact same thing with CSS. It does not matter if the code is added to HTML or CSS.

And for me, at least, this is not a spiritual debate. On the contrary, this is a very practical debate. The popularity of the tool and the signal it conveys absolutely has consequences on all of the development community. Whether I like Tailwind or not, I have to maintain projects that were done with it, I get asked about it, etc.

I think that saying "it's just a tool" is kind of short-sighted. It's a paradigm. And as such, its practical implications are far reaching.

Re:Tailwind CSS v3.3 by imbnwa on Wednesday March 29, 2023 @09:57AM (#35357343)
>The popularity of the tool and the signal it conveys absolutely has consequences on all of the development community

I'm stuck on some rather legacy (read: fashionable 5 years ago) stack either way, but its interesting that I'm conducting an interview later today where the applicant ensured to exhibit a Next/Tailwind/TS app that runs on Vercel.

I can't blame them either, I remember interviewing two summers ago and being asked if I had experience with Next straight out the gate despite it not being mentioned anywhere in the job description.

Re:Tailwind CSS v3.3 by graboidhunter on Wednesday March 29, 2023 @09:51AM (#35357274)
It is a philosophical debate about the relationship between HTML and CSS.

The "traditional" approach to authoring HTML and CSS is predicated upon on idea of separating concerns. The idea is that your HTML should not depend on your CSS, and your CSS should not depend on your HTML.

The "utility-first" approach reacts by claiming this is wrong. It goes on to reason that either HTML depends on CSS or CSS depends on HTML, but neither are independent. This is what Adam Wathan calls "dependency direction."[0]

0. https://adamwathan.me/css-utility-classes-and-separation-of-...

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:13AM (#35357572)
Again, it's not only philosophical nor spiritual. It has numerous practical implications for any dev engaged in Web work.
Re:Tailwind CSS v3.3 by graboidhunter on Wednesday March 29, 2023 @11:06AM (#35358337)
The debate is philosophical. The debate has practical implications. These two ideas are not mutually exclusive.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @04:02PM (#35362601)
I should have said: "it's more than a philosophical debate".
Re:Tailwind CSS v3.3 by ghc on Wednesday March 29, 2023 @10:24AM (#35357731)
Tailwind solves a communication problem, not a technical problem. It's extremely common on large teams to have people come and go. The more complex your CSS is, the more time it takes to train someone new. Think of it as a standard library for CSS.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @11:02AM (#35358286)
But we can have a native, standard library for CSS. No need for Tailwind if this is the problem to solve.
Re:Tailwind CSS v3.3 by ghc on Wednesday March 29, 2023 @02:36PM (#35361338)
A standard library without widespread adoption is just a library. Adoption is the hard part.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @04:03PM (#35362621)
You can make it mirror Tailwind's nomenclature if you want it.
Re:Tailwind CSS v3.3 by madeofpalk on Wednesday March 29, 2023 @08:50AM (#35356489)
I don't think tailwind is the right solution, mainly because there's just zero type safety with it. The ergonomics are terrible for knowing what options you have available, and whether you made a mistake or not.

> if you do your CSS right

I think the reality is, when you hit a certain size and scale of developers working on your product, it's next to impossible to do CSS "right". It's just not a skill that's widely shared in large frontend teams - a part of this is that the role of a "frontend developer" is pretty broad now. There's a lot of frontend work where you just don't end up styling things.

This is why you might want to abstract out HTML is styled one level up, and then go from there. Having a good framework for people to style things consistently, and then create higher and higher level components for all the common patterns.

Personally, I think the better solution for this (as opposed to tailwind, not "let everyone write their own bare css") is something like Vanilla Extract's Sprinkles to create your meta framework for styling with full type safety and editor suggestions https://vanilla-extract.style/documentation/packages/sprinkl...

Re:Tailwind CSS v3.3 by bryanrasmussen on Wednesday March 29, 2023 @09:14AM (#35356778)
>There's a lot of frontend work where you just don't end up styling things.

the problems these things all try to solve are not so much how to style things, but how not to have the cascade bite you because your devs didn't understand that part.

So how to describe that a problem - is it a CSS data model problem?

Re:Tailwind CSS v3.3 by imbnwa on Wednesday March 29, 2023 @09:58AM (#35357366)
Doesn't BEM equally solve the cascade?
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:14AM (#35357585)
Yes. But it creates the problem of naming everything. Which is clearly a problem in itself.
Re:Tailwind CSS v3.3 by bryanrasmussen on Wednesday March 29, 2023 @12:27PM (#35359538)
well part of the whole discussion up was that BEM was a crappy solution, really the best solution is to know how stuff works so you make your solution correctly.

But because some people don't know how stuff works you come up with rules that if they follow they won't mess stuff up. They won't make things in the best way, but they won't screw stuff up either. hurray!

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:53PM (#35362447)
Yes! And that's the whole point I guess. What's the best, cheapest, simplest way of preventing these mistakes?

I think simple linting could be part of the solution.

Re:Tailwind CSS v3.3 by bryanrasmussen on Thursday March 30, 2023 @03:21AM (#35369239)
the best way is the most remunerative way as well, which is that people know how to do things correctly, knowing how to do things right means that people make less mistakes, making better things.

However this is not the cheapest (because costing learning time) or simplest way.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @09:06AM (#35356667)
Yes, I see. It's a way of limiting the damage done by careless CSS developers. But couldn't these mistakes be flagged easily through linting only?
Re:Tailwind CSS v3.3 by madeofpalk on Wednesday March 29, 2023 @09:36AM (#35357088)
Outside of agency land building bespoke brouchure websites, I've never seen companies hire "CSS Developers". Closest would be hiring developers to work specifically on design systems/component library.

I think it's useful to think about analogies for other parts of the tech stack. You probably don't want every backend developer writing SQL by hand every time you interact with the database, so you create various levels of abstraction on top of that to "limit the damage done by careless SQL developers".

The negative sentiment ("careless CSS developers") isn't necessary. It's not about fixing the problems from bad developers doing bad things, but just giving people better alternatives to make it not possible for anyone to do "bad" things.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:20AM (#35357691)
Sorry about the "careless" bit. Maybe I could have chosen a better word.

I get what you're saying. But again, linting should be enough to guide you in writing good CSS. It's really not that hard if we are interested. No need for a whole new way to do it. What I generally get from discussing about it here or elsewhere is that lots of devs just don't like CSS. Which is a shame since it's central to our work as Web devs. What do you, yourself, think about this?

Re:Tailwind CSS v3.3 by datavirtue on Wednesday March 29, 2023 @01:21PM (#35360308)
"The ergonomics are terrible for knowing what options you have available"

I installed a vscode extension and just hit CTRL+SPACE to see what my options are.

Re:Tailwind CSS v3.3 by davnicwil on Wednesday March 29, 2023 @09:20AM (#35356880)
Maybe it's less about representing good/bad CSS and more about representing the CSS people typically write in the wild.

I guess if people only wrote really good CSS in the wild, or hey even agreed upon what it looks like, there would be no need for tailwind, that's true. But that's not reality.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @09:34AM (#35357065)
I see, yes.

But could we not care and try to use this native language as it was designed instead of short-circuiting it by slapping costly dependencies on top of it? Wouldn't it be a better approach considering, among other things, the coming ressource optimization in HTTP3?

Re:Tailwind CSS v3.3 by that_guy_iain on Wednesday March 29, 2023 @09:22AM (#35356912)
I'm using tailwind in one of my projects. As a normally backend dev, I find tailwind rather weird. It seems very much like it just gives you classes for every css property&value match. It seems very much like I'm just writing the css but in a different way. cursor-pointer class for "cursor: pointer" for example.

However, I find the responsiveness side of things very useful.

Re:Tailwind CSS v3.3 by tough on Wednesday March 29, 2023 @09:29AM (#35356998)
Yeah that's precisely what it is at the end of the day
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:29AM (#35357807)
What do you mean by responsiveness?
Re:Tailwind CSS v3.3 by that_guy_iain on Thursday March 30, 2023 @05:29AM (#35370117)
You can use md:class-name so that when the screen size is the size for medium then that class will be used. An easier way to do the screen size stuff.
Re:Tailwind CSS v3.3 by emmacharp on Thursday March 30, 2023 @05:59AM (#35370312)
Easier, like in less characters? Because I wouldn't say using CSS media queries is hard.
Re:Tailwind CSS v3.3 by that_guy_iain on Thursday March 30, 2023 @06:11AM (#35370406)
It's not that hard but it's more work than I would like to do as a backend developer. Realistically, I want to put as little work as possible in to frontend and focus on backend.
Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @12:08PM (#35359249)
Yeah, tailwind isn't intended to make it so you don't have to learn CSS. It very much tries to map to CSS fairly directly, so it wouldn't prevent you from needing to learn it.

> I'm just writing the css but in a different way. cursor-pointer class for "cursor: pointer" for example.

The difference is, when writing the CSS yourself you also have to find a way to apply this to the thing you want it to apply to. Which means you have to write your own selector. Which gives you 1000 guns pointed at your feet, and maybe two aimed away from you (and one of those is just the same one that tailwind gives you, but less portable).

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @04:05PM (#35362668)
With simple linting, I think, you could make sure to disable the vast majority of these guns. But I care to hear your take about it.
Re:Tailwind CSS v3.3 by that_guy_iain on Thursday March 30, 2023 @06:50AM (#35370713)
> Yeah, tailwind isn't intended to make it so you don't have to learn CSS. It very much tries to map to CSS fairly directly, so it wouldn't prevent you from needing to learn it.

For me, a framework should deal with the basics and make thing easier. Making it so you just write css differently seems odd for a framework. It seems more like a css parsing framework than anything. The tailwind UI seems like a framework that provides you the basics.

Re:Tailwind CSS v3.3 by swyx on Wednesday March 29, 2023 @09:41AM (#35357153)
i think you're kinda proving his point. it's easy to write "BAD CSS". I write "BAD CSS". you may be so good you only write GOOD CSS. i'm not. I may never be as good as you. tailwind is a framework for people like me. (there are lots like me)
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @09:59AM (#35357379)
CSS is really not that hard to understand and use adequately. And as I said here, linting should be more than enough to nudge you in the right direction, CSS-wise.

Or maybe you don't like CSS at all?

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @12:01PM (#35359151)
Are you managing the entire front-end stack? Or just design?
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:50PM (#35362391)
It depends on the project. More HTML and CSS than JS. But, as I said, the team has been generally using the Tailwind paradigm for 5 years now. The team has also been divided for while about it. Heheh.
Re:Tailwind CSS v3.3 by mhoad on Wednesday March 29, 2023 @02:20PM (#35361142)
I also used to feel like the comment you were replying to. About two years ago I decided to try and lean in heavily towards “modern” CSS and honestly things have gotten so much better the past few years.

I also leaned in heavily to the component model with Web Components which was another huge win for my experience with CSS.

I actively enjoy it now rather than dread it. Catching up wasn’t too difficult and if someone else is in the same boat I would recommend the investment.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:51PM (#35362405)
My thoughts exactly!
Re:Tailwind CSS v3.3 by Xeoncross on Wednesday March 29, 2023 @09:57AM (#35357353)
If Shawn can't write good CSS, I'm hopeless
Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @09:51AM (#35357278)
I posted your thoughts on the Tailwind chat. I’m trying to push Adam or one of the other leads to come on and post a proper response.

I completely disagree with your opinion, as well as numerous other Tailwind developers lol.

Your opinion of Tailwind is kind of the like what the person who may have believed the flat head screw was the way when they introduced the Phillips head screw. Both types of screws are great tools, but a Phillips head may have seemed less superior to you because you didn’t understand its purpose and value.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @09:56AM (#35357340)
That's great! I'd love to have a proper response as you say.

As for your analogy, I'm not convinced it's adequate. The Phillips screwdriver does not reinvent the way to turn screws as Tailwind does here with styles. The Phillips screwdriver does not add complexity in the building of houses.

Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @10:11AM (#35357547)
They aren’t reinventing the way you write styles. Tailwind is actually just a CSS design token and utility class library at its core. It’s the Bootstrap of the 2020’s.

Regarding design tokens, they are taking notes from 1996, and they realized that it is much more computational efficient to describe your component visually with inline styles compared to loading separate style sheets.

Tailwind and CSS design tokens in general make it easier to make smart, efficient choices from curated palettes. Design tokens also create a common language for everyone who uses Tailwind - both across teams and across projects, which can break down communication barriers in large scale projects.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:28AM (#35357796)
I agree wholeheartedly about design tokens. I use this in every project, always. But I only need custom properties, nothing else. And I get all the advantages you're describing.

And I'd say that striping the cascade, removing selection and specificity and implementing new ways to do the same things (ie: peer-[:nth-of-type(3)_&]:block) is indeed reinventing our use of CSS.

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @12:05PM (#35359211)
If you name your own tokens, then other people coming to the project have to learn to apply the same set of tokens correctly, and may even end up reinventing the same ones with new names. In fact, you might even do that (well, it sounds like you might not, but I certainly would, and have)

Tailwind is just that, but unified across all projects, with better tooling (VS code integration, tree shaking, lighter css files)

Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @03:01PM (#35361684)
PC, is that you?

I’ve been working towards emailing you to ask if I could upgrade patrickcollison.com

Re:Tailwind CSS v3.3 by pcthrowaway on Wednesday March 29, 2023 @03:12PM (#35361844)
Since this is an anon account, I have a policy of neither confirming nor denying being any person, real or fictional.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @04:01PM (#35362579)
You can use the same standardized nomenclature in CSS if you want it to be "compatible" with Tailwind. Nothing wrong here.
Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @03:07PM (#35361761)
So this is where Tailwind comes into play. With TW, you don’t need to any custom properties. They include base stylings and preflight styles that fix and reset just about any browser quirk or bug. The end result is a consistent styles that look and function exactly the same on any device or browser.

There are hundreds of little tiny css style rules and fixes for a perfect website, and you have to remember them all. Tailwind has done all of that, plus a bunch of more.

Their utility classes are their biggest feature in my opinion. Just the ability to set dark mode styles inline with my light mode styles seal the deal for me alone.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:58PM (#35362538)
Again, I agree the base stylings etc. I do the same in each of my project using pure CSS specifically because I don't want to remember them all.

So I have all the same kind of files, and change the design tokens accordingly. The only difference is I configure in CSS whereas you configure in JS. You can bundle it all and keep reusing the same files as you would do in Tailwind.

Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @05:28PM (#35363982)
Yeah, it’s pretty much the same difference.

For someone starting a brand new app from scratch, they might want to lean on existing css design token libraries.

Design tokens aren’t anything new; Bootstrap has been using them for margin for years. mr-1 mt-2

Re:Tailwind CSS v3.3 by hoofhearted on Wednesday March 29, 2023 @10:13AM (#35357569)
Your thoughts kind of remind of Brandon M’s lol.

https://news.ycombinator.com/item?id=9224

Re:Tailwind CSS v3.3 by enkrs on Wednesday March 29, 2023 @09:54AM (#35357311)
Maybe one point not raised enough in the eternal discussion between Tailwind vs CSS properly is the cognitive load of naming and organizing things.

To do CSS properly, you need to name classes, you need to come up with CSS cascades that work.

Being programmers we would love to categorize and name things all day long. Ever heard how we over-engineer things because of the DRY principle?

But we would love to name classes and do CSS properly only theoretically. In practice, we run out of time making CSS with nothing to show a week into the task except a CSS kitchen sink demo. By the time we're done, the scope of some component has grown in a way we did not expect and is hard to represent without markup change.

Tailwind on the other hand removes the task of thinking how to name the thing we're making. A appbutton appbutton--state-user-notallowed or a touchbutton touchbutton--disabled? In Tailwind it's just a a blue-600 rounded rectangle. Scope changed? No problem, now it's a green-400 shadow special rectangle, without checking where else it was or will be used or coming up with a new name for this special rectangle.

It's just faster. Not strictly better.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:06AM (#35357469)
The naming of every little thing in CSS is what I call a "pseudo-problem" in the original post.

You don't have to name classes for everything inside a component. You only have to name the component, as in Tailwind. Afterwards, tag selection is totally fine. And with all the new CSS pseudo-selectors it is now easier than ever to be styling with low specifity while including markup options.

Re:Tailwind CSS v3.3 by ethanbond on Wednesday March 29, 2023 @11:01AM (#35358268)
If you don’t name it then it’s sensitive to DOM changes which can look completely inert in the file in which they occur.

Have you actually used Tailwind for a week or more?

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @11:27AM (#35358651)
Yes I have. For a couple of years and my team still uses it.

But Tailwind is sensitive to DOM changes too, since every style is on tag. You wouldn't remove any tag without understanding its usage in a component using Tailwind. Why would you treat a CSS component any other way? If a tag's there, it must be used for something. Again, I may miss something but I see that as normal care and dilligence in both ways.

On a sidenote it's now easy to include, for example, all headings to be styled the same in a component, thereby limiting the need to adjust the CSS in case of a change of tag. There are many ways now to leave markup options opened if need be.

Re:Tailwind CSS v3.3 by weo3dev on Wednesday March 29, 2023 @06:44PM (#35364933)
Your belief that you must use classes to apply CSS is false.

CSS is a generalization programming language, with specificity meant to be used for _exceptions_. Therefore, CSS should be used with general statements first, contextual statements next, utilitarian statements following, and then and only then exception-specific declaration in the edge cases they are needed.

Programming with CSS the way it was intended: Cascade, Inheritance, and then specificity, generally produces a quite DRY experience.

The one thing engineers/other programmers seem to have missed, continue to miss and seem intent on missing into the future is this: CSS is a static programming language that must account for being in and rendering dynamic contexts.

When I'm in JavaScript, I _depend_ on having the one thing, be the one thing, whenever I reach for it. I depend on immutability to keep my life sane.

When I'm in CSS, I _must_ account for flexibility, because I cannot predict the future, and I cannot predict all the various contexts in which my declaration might exist. Therefore, each CSS statement I create is based on how I would _like_ my thing to behave based upon a variety of circumstances, and to have static fallbacks when all else fails. My sanity is in producing the most responsive yet stable experience for the unknown.

Tersely, but without apology: Tailwind is for developers who do not want to take the time to learn CSS the same way they took time to learn JavaScript [or insert language of choice].

Re:Tailwind CSS v3.3 by mfsch on Wednesday March 29, 2023 @10:04AM (#35357449)
The way I see it, the problem is the C in CSS. If you rely on `.author-bio > h2`, then every time you make a change to `.author-bio`, you have to consider all the contexts in which this class may be used globally in your site, and if you change the styles for `h2` even more so. Sure you can say you encapsulate every context with a globally unique id, but since you’re probably already using some kind of templating system for you HTML, it’s easier to specify the styles there. It’s basically the difference between having variables scoped global vs. local by default.
Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @10:10AM (#35357534)
The « > » part should not be necessary 90% of the time.

And while using Tailwind, I still have to know where I include my components. I still need to test different instances in different places.

With that in mind, I don't see the added benefit of Tailwind here (again, other than limiting the damage done by careless devs). Maybe I'm missing something?

Re:Tailwind CSS v3.3 by waldothedog on Wednesday March 29, 2023 @10:34AM (#35357887)
No argument here. But I believe, as others have suggested, that Tailwind is for people who have given up on (or aren’t motivated enough to pursue) the idea that they can /ever/ learn CSS.

Adopting Tailwind is easier than thinking about CSS, even if they end result is (IME) just as wonky and disjointed as a ‘bad css’ implementation

Re:Tailwind CSS v3.3 by ch4s3 on Wednesday March 29, 2023 @10:41AM (#35357972)
I can see where this comes from, but in my case Tailwind is nice because while I know a good deal about CSS it is far from my core competency. Tailwind offers me a well organized toolbox of things that are all good enough, but more importantly easy for me to use pick up and use occasionally. It is also something that I can work in with both FE and BE engineers, it provides a nice lowest common denominator.
Re:Tailwind CSS v3.3 by waldothedog on Tuesday April 11, 2023 @10:02PM (#35534169)
Hmm, ya know after thinking about your reply… I could see there being a way of executing TW that increases the chances of higher quality FE—-and probably make refactoring safer and more systematic to boot.

Unfortunately, I haven’t experienced this :/ (yet)

Re:Tailwind CSS v3.3 by datavirtue on Wednesday March 29, 2023 @01:18PM (#35360264)
Partially true. I had (once upon a time) mastered CSS to the point of being able to make pixel perfect documents. I understand CSS, that is WHY I use Tailwind.

CSS is the low level language of styling. For the same reason I use C# or Javascript instead of assembly language or C, I need to get shit done.

Re:Tailwind CSS v3.3 by ianbutler on Wednesday March 29, 2023 @12:28PM (#35359566)
I think most developers simply don't care about this, I know I don't*. I don't see CSS as some beautiful thing I should tweak and spend time naming and doing "right". I want to be able to slap some class names onto things that quickly make it look the way I want, with a system I know others will be able to grok almost immediately with a high level of consistency and get back to building the features that are actually going to attract customers and generate more value.

The advantage of Tailwind is commoditizing CSS into something no one has to really think about as deeply as you're suggesting we do. Someone who cares to can do that thinking and put it into a Tailwind class in one of the versions. It's also portable, in that anyone who works with Tailwind can come in and immediately contribute, instead of figuring out whatever structure we've built ourselves.

Tailwind provides me a lot of value in that it lets me continue building while providing a very nice UI (which is required in modern times) and not having to engage too deeply with styles, because I'm not trying to be a master of CSS, I'm trying to build a wholistic product and I have 500 other things I need to do.

* I'm a backend guy but recognize I need nice UIs.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:41PM (#35362256)
Well, I wouldn't say it's about CSS being a "beautiful thing". It's about delivering great experiences to our users, experiences that use our native tools in an optimized way.

Because, you can ship the same experience with less code, less dependencies, less complexity. You can better serve users by easily catering to their preferences via the cascade. You can make use of new technologies that increase performance (see, among others, HTTP3). You can profit from the newest supported CSS properties that are way more expressive and give you more flexibility for cheaper.

It's about trying to do the right thing.

Re:Tailwind CSS v3.3 by ianbutler on Wednesday March 29, 2023 @06:46PM (#35364956)
I think right is subjective here, I don't believe it's clearly right for me or my projects.
Re:Tailwind CSS v3.3 by emmacharp on Thursday March 30, 2023 @05:55AM (#35370286)
It can be, yes. But I was talking more about "right" for the end user which should be less subjective (I think).
Re:Tailwind CSS v3.3 by lcnPylGDnU4H9OF on Wednesday March 29, 2023 @02:10PM (#35361005)
Is there a way to implement responsive inline styling (e.g. class="flex-col lg:flex-row") in pure CSS? I remember thinking a lot about what Tailwind offers and I came up with that and a vague sense that I probably just don't know CSS well enough to have an opinion I'm comfortable with.

Edit: I guess this question kinda doesn't make sense. There's a lot of CSS syntax that isn't available inline in the style attribute and the example I gave can be done with "traditional" CSS classes. The thing I'm really considering is how one can semantically choose HTML elements while using small bits of inline "styling" (read: atomic CSS classes masquerading as styles) to change the properties which need changing and forego CSS otherwise.

Anyway, ultimately I don't think that's necessarily better than other styling implementations.

Re:Tailwind CSS v3.3 by andrei_says_ on Wednesday March 29, 2023 @02:33PM (#35361307)
I think another advantage of using the framework is that one does not need to learn CSS in depth and in detail.

I have learned CSS and absolutely love the cascade. If I hadn't, and was on the clock, I'd consider something more shortcut-like, even if it's less precise.

If I was using React, writing components in the way SPAs require, Tailwind could make more sense. SPAs fragment code into such little pieces, that thinking about CSS as a whole becomes less necessary.

But, I do know CSS, I have adopted the ITCSS code structure, I do have the Tailwind colors in my SCSS codebase, use the Utopia fluid typography and spacing scales, and with grid, container queries, flexbox, gap etc. life is good. CSS is fun.

Re:Tailwind CSS v3.3 by emmacharp on Wednesday March 29, 2023 @03:44PM (#35362311)
It is, as of now, the only argument I've read that sticks. Lots of devs do not like CSS. And this is a way for them, as you said, to skip understanding the language.

But, is it a "good" argument though?