Live data from Hacker News

Play with TailwindCSS in the Browser

play.tailwindcss.com

281–290 of 300 posts

Re: Play with TailwindCSS in the Browser

#281
post #40

Earlier quoted context omitted.

It’s like you have to learn every raw CSS selector, and then also learned how it’s represented in Tailwind, and then scatter that all over your markup. That's exactly what it is. But... you have to do that regardless of what you use for CSS layout. If you're not using Tailwind (or something like it) then you're going to end up creating classes using the raw CSS, and then naming them yourself, and then having to remem…

> you're going to end up creating classes using the raw CSS A program can read what looks like inline css and produce class names for youand put those in class files. When developing your see "height 20px" In your app its compiled to "h-20" with a css file "h-20: height 20" This is better because you don't have to learn another way to express the same logic.

Why not use actual inline CSS instead of that?

Re: Play with TailwindCSS in the Browser

#282
post #105

Earlier quoted context omitted.

I've used Tailwind on many projects at work for about a year now. I do not like it. Tailwind seemingly affords an easy way of writing inline styles, but it 1) clutters the HTML, 2) leads to repetition and makes people break the DRY principle (yes, you should extract to components, but people don't always do that), 3) uses names that can be similar but are not identical to CSS properties and feels like a bad abstracti…

I actually love Svelte, but generally feel much more productive in React, in part, because Tailwind seems to work better with it.

What do you mean by tailwind works better?

Also, this is the first I’ve heard anyone proficient in both consider React more productive! I’m curious, do you think that has more to do with the amount of experience you have in React over Svelte?

Re: Play with TailwindCSS in the Browser

#283

Earlier quoted context omitted.

Cascading is excellent for websites. Terrible for applications. There's no concept of anything even remotely similar in any other UI technology. Native applications have use the "scoped component" paradigm for decades, and the web is finally catching up.

This is the crux of it really. It makes a whole lot of sense to have cascading styles in documents. I don’t want to have to explicitly set a text colour for each individual paragraph. But the opposite is largely true for UI elements. For one, I’m probably using some external templating or component framework to repeat them, because they mostly likely have behaviour attached and HTML by itself has no good story for th…

> This is the crux of it really. It makes a whole lot of sense to have cascading styles in documents. I don’t want to have to explicitly set a text colour for each individual paragraph.

But that’s what you’re doing when you use scoped styles, components, Tailwind etc.

Just set it once, on body and forget about it for the lifetime of your app.

> I pretty much never want their styling to be modified by the context in which they’re used.

I guess we have worked on different projects. To me this sounds like the edge case. Most projects I’ve worked on want all the components/widgets/thingies in one consistent style that works together for a cohesive overall experience. For such situations (which to me feel like the majority case) the cascade is the simplest tool.

Re: Play with TailwindCSS in the Browser

#284

Earlier quoted context omitted.

I actually love Svelte, but generally feel much more productive in React, in part, because Tailwind seems to work better with it.

What do you mean by tailwind works better? Also, this is the first I’ve heard anyone proficient in both consider React more productive! I’m curious, do you think that has more to do with the amount of experience you have in React over Svelte?

Possibly, but Tailwind makes things so much faster for me. React has "better" developer tools. Perhaps I'm less proficient in Svelte, Rollup is still cryptic to me, and I haven't taken the time to use Vite/Kit yet.

Oh I think the other thing was Svelte doesn't work as well with Typescript (or I couldn't figure out how to make it work as well). I wouldn't get type hints in situations where I would with React.

Perhaps I just didn't take the time to get things set up properly. If you can link a Svelte project that uses Tailwind and Typescript I'd love to give it a clone and see if things work better.

Regarding productivity, I don't think I'm "less" productive in Svelte, especially for smaller apps. I think I've been really conditioned by React and have an easier time splitting out components and making things more modular, which makes a big difference with larger apps.

Re: Play with TailwindCSS in the Browser

#285

Earlier quoted context omitted.

The killer for SASS nowadays is CI. You're either using the (ancient, slow) Ruby implementation of SASS, or node-sass which requires a native binary build and causes headaches across environments. Furthermore, with Post-CSS, the feature set of SASS has been completely subsumed by the latest CSS standard. There's really no good reason to use it anymore.

You should really be using the dart-sass[0] build (just `sass` on npm). None of the headaches of native binaries or using ruby, its pure JavaScript (its a dart codebase transpiled to JS). It is very fast. [0]: https://sass-lang.com/documentation/#older-versions

>[0]: https://sass-lang.com/documentation/#older-versions

This is awesome, really glad to see things have progressed from the node-sass days. Might have to give it another look.

Re: Play with TailwindCSS in the Browser

#286
post #254

Earlier quoted context omitted.

That's the biggest problem with TW IMO. It's much more difficult to scan a list of classes in a single line. With CSS I can quickly scan the declarations from top to bottom until I find the thing I want. Complex nested declarations are also super easy to scan when using SCSS. When you start adding pseudoclasses with TW it becomes a shit show. And it really makes the markup an absolute mess for anything other than tri…

explain to me how this compiles .class1 { .class2 { &:hover { font-family: value; } body.some-thing & { color: woooooo; } } }

I guess the point you're making is that TW prevents you from making certain errors.

Which is technically true but irrelevant. TW doesn't prevent you from understanding fundamental CSS concepts such as the box model, cascading, etc. Anyone with even basic CSS knowledge would not write this nonsensical and malicious example you just used.

Re: Play with TailwindCSS in the Browser

#287

Earlier quoted context omitted.

explain to me how this compiles .class1 { .class2 { &:hover { font-family: value; } body.some-thing & { color: woooooo; } } }

I don't think the example compares. In languages like JS, double, triple or even further nested ternaries are possible. But terser isn't always better because human readability is important. I can easily understood your SASS example because I know SASS, but I'd never write it like that. If I really wanted to add a decedent selector from a body class to .class1, I'd start a new nest on the body tag. The problem with T…

> I really think this is a fad a lot of people are going to come to regret when they go back to maintain older projects based on it.

Yeah 100%

But if you look at the State of CSS survey, TW is still relatively not as popular as Twitter or HN would make you believe.

https://2021.stateofcss.com/en-US/technologies

Re: Play with TailwindCSS in the Browser

#288

Earlier quoted context omitted.

This is the crux of it really. It makes a whole lot of sense to have cascading styles in documents. I don’t want to have to explicitly set a text colour for each individual paragraph. But the opposite is largely true for UI elements. For one, I’m probably using some external templating or component framework to repeat them, because they mostly likely have behaviour attached and HTML by itself has no good story for th…

> This is the crux of it really. It makes a whole lot of sense to have cascading styles in documents. I don’t want to have to explicitly set a text colour for each individual paragraph. But that’s what you’re doing when you use scoped styles, components, Tailwind etc. Just set it once, on body and forget about it for the lifetime of your app. > I pretty much never want their styling to be modified by the context in w…

>Most projects I’ve worked on want all the components/widgets/thingies in one consistent style that works together for a cohesive overall experience. For such situations (which to me feel like the majority case) the cascade is the simplest tool.

This is the distinction to me. New methods in composing a page approach this differently: style consistency is maintained through dependencies and a build process rather than relying on context. To understand the styling I'm applying to a given HTML elemnt, I can look to the packages going into the build (just as a I do with other aspects of the code) rather than needing to understand every context my component could possibly be invoked within.

Re: Play with TailwindCSS in the Browser

#289

Earlier quoted context omitted.

This isn't meant as a contradiction of your point, but there are plenty of ways to use component-based architectures with server-side rendered apps, too, like GitHub's ViewComponent gem for Rails. https://viewcomponent.org Also, I'd go so far as to say that if you're not using a component based architecture for your web app's view layer, you're creating a ton of extra work for yourself.

I’d add you don’t even need ViewComponent. Layouts, partials, variants, and helper functions provide plenty of heavy lifting options when it comes to refactoring your HTML. My take on ViewComponent: it’s what helper functions become when they grow up into proper objects. Great for larger projects, may be more infrastructure than necessary for smaller ones, adopt incrementally when they seem compelling.

Don't need it, but I've found ViewComponent to be a big win over partials. Being explicit with the available state instead of implicit has helped me catch plenty of bugs.

Re: Play with TailwindCSS in the Browser

#290

Earlier quoted context omitted.

> It's basically the point of cascading style sheets The "cascading" part is what makes it incredibly complicated. Keeping the "cascade" in sync with the actual markup is not a trivial task in teams with many people of different skills levels. Not everyone is a top 1% dev, so we need easier and safer tools so that everyone can work and maintain a codebase. > Sticking to proper class names and elements makes reskinnin…

You're just shifting work though. The commit will now contain 10000 non html structure changes to an html, phtml, whatever, instead styles to a CSS sheet. Might as well go back to doing inline styles. There's a reason we don't do that anymore.

> The commit will now contain 10000 non html structure changes to an html

It's an acceptable trade off. Nothing is perfect. In exchange you're guaranteed those changes only affect this markup, and not some other li > ul > a whatever somewhere else.

> Might as well go back to doing inline styles

No, it is not. This has been explained thousands of times anyone says "tailwind is like inline styles". You can do responsive, you're limited to a consistent subset of rules, minimal output css file, caching, etc, etc. For example, here [1] is an explanation why it is not the same, but there are thousands.

By reading your answers I deduce you've not used it yet. And this is exactly what is being discussed here. Fanatics closed inward looking people will never like it, nor anything that defies what they've been taught for years. Like religion almost. You have to try it for real to see the benefits. It is not perfect, but the net result is very positive for a lot of people as you can see from the usage statistics. Just be a bit more open minded to new tech and give it a try. At least you'll understand why it is not the same as inline styles which is a pretty basic thing you understand after 1 hour of using it.

[1] https://frontstuff.io/no-utility-classes-arent-the-same-as-i...

Post reply on HN