News for hackers. Stuff that matters.
Re:Play with TailwindCSS in the Browser by rco8786 on Friday June 10, 2022 @07:58AM (#31692810)
Im sorry but I don’t understand how anyone can look at that and think it’s a good way to build UIs. I’m almost certainly in the wrong, considering how popular this library seems to be getting, but holy heck that looks like a tedious mess to work with. 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.
Re:Play with TailwindCSS in the Browser by onion2k on Friday June 10, 2022 @08:32AM (#31693143)
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 remember what you called them. Hopefully you're good at that and you can remember, else you'll duplicate things. Hopefully your entire team are aligned on the same naming conventions, or your project's styles will be a total mess.

Maybe you'll use styled-components or another CSS-in-JS solution, which helps a bit by making your styles scoped to components so they don't interfere with things outside of where they should, but then you'll have to keep a set of constants to use across all of them anyway, which puts you back at the same problem as plain CSS - you need to remember what's been set, and not duplicate things.

Ultimately, Tailwind is a really well designed abstraction of inline styles that means you don't have to worry about inconsistency and duplication of things any more. It's another thing to learn but because it's so similar to raw CSS it's not actually a lot of effort. It works well.

Re:Play with TailwindCSS in the Browser by the_other on Friday June 10, 2022 @09:22AM (#31693795)
> 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 remember what you called them.

This is true. But if we better taught the cascade and promoted the idea of global styles rather than pretending it's a problem then more people would be better at this and the problems would gently recede.

We (the high-end front-end dev community) have fallen into the habit of using class names where we really wanted IDs and using components when we really wanted global styles. I feel we have been pushed in this direction by developers who didn't understand the technology properly. The Tailwind author clearly understands it, so I'm not targeting them... but they are supporting the people who don't see why the cascade is useful.

We have megabytes of code to create the impression of global consistency (components, style libraries, CSS-modules...) shipped to millions of users every hour. Browsers do that for us already. Embrace the simplicity of

button { border: foo; color: bar; } .callout button { color: aux; }

It's so clear, so elegant. The obsession with modularising everything, and then applying a DSL to get between the modules, makes the language's inherent convenience, elegance and clarity so much harder to work with that it boggles my mind.

Re:Play with TailwindCSS in the Browser by 1shooner on Friday June 10, 2022 @10:19AM (#31694581)
> It's so clear, so elegant.

The thesis of Tailwind is that the cascade actually becomes very unclear and inelegant at scale, and I would say the reason it's so popular is that many devs share that experience.

Re:Play with TailwindCSS in the Browser by ramesh31 on Friday June 10, 2022 @11:11AM (#31695279)
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.
Re:Play with TailwindCSS in the Browser by deergomoo on Friday June 10, 2022 @03:19PM (#31698332)
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 that. For two, I pretty much never want their styling to be modified by the context in which they’re used.

Re:Play with TailwindCSS in the Browser by the_other on Saturday June 11, 2022 @06:31AM (#31703437)
> 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 by 1shooner on Saturday June 11, 2022 @04:13PM (#31707889)
>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 by ryanf on Friday June 10, 2022 @10:28AM (#31694700)
We collectively tried the approach you’re describing, and we stopped doing it because it sucks. It looks nice in simple cases, but the lack of encapsulation or locality makes it impossible to change upstream styles without breaking something somewhere else. Also you have to use horrible BEM-style names to avoid accidental collisions between styles from different parts of your app, which kind of ruins the elegance in itself.
Re:Play with TailwindCSS in the Browser by jsf01 on Friday June 10, 2022 @10:43AM (#31694913)
If your projects are small enough that relying on the cascade is a reliable option, you probably don’t need tailwindcss. If you’re working with 50+ devs on the same code base with many moving parts and shared components, you can’t afford to verify whether the cascade breaks something on every single change. So imo there’s nothing inherently wrong with your post, it’s just that tailwindcss doesn’t really excel until you’re working with a bunch of people authoring css in a shared codebase. (That said, now that I’ve drunk the kool aid I use tailwind or windi css even on my own projects. It’s pretty great once you know it.)
Re:Play with TailwindCSS in the Browser by andiareso on Friday June 10, 2022 @09:42AM (#31694074)
But this isn't much different than:

<Button class=`border text-gray ${override}`/>

<CalloutButton /> extends <Button override="text-blue" />

I'd argue you have less markup to write overall if you are modularizing component logic/styling

Re:Play with TailwindCSS in the Browser by meowtimemania on Friday June 10, 2022 @04:00PM (#31698760)
One gripe I have with tailwind, is overriding styles is difficult. The .text-blue style will only override .text-gray if it is declared later in the css document.

for example if the corresponding css file is this: .text-blue { color: blue; } .text-gray { color: gray; }

Then in your above example, both Button and CalloutButton will have gray text because .test-gray has higher specificity than .text-blue

Re:Play with TailwindCSS in the Browser by xigoi on Saturday June 11, 2022 @05:34AM (#31703171)
The difference is that your website will be much larger and won't work without JavaScript.
Re:Play with TailwindCSS in the Browser by LouisSayers on Friday June 10, 2022 @10:34AM (#31694784)
And what about your :hover, ::before etc, where do you put those? (genuinely curious)
Re:Play with TailwindCSS in the Browser by timdorr on Friday June 10, 2022 @12:05PM (#31696034)
Re:Play with TailwindCSS in the Browser by seek on Friday June 10, 2022 @12:05PM (#31696043)
Re:Play with TailwindCSS in the Browser by azangru on Friday June 10, 2022 @11:55AM (#31695883)
> Hopefully you're good at that and you can remember, else you'll duplicate things. Hopefully your entire team are aligned on the same naming conventions, or your project's styles will be a total mess.

  - CSS classes can be named on a per-component basis, according to one of the well-established naming conventions (BEM, SMACSS, or whatever). This does not require remembering the names of other classes.
  - With the arrival of web components, styles can be scoped within the shadow DOM; and the name collision becomes a non-issue; as well as keeping track of _all_ the CSS that's written in the project. If CSS classes don't leak, you can focus your attention only on a given component and ignore the rest.
  - Instead of CSS-in-JS, one could use CSS modules, which are just regular CSS with a build step. The relevant project-level (site-level, page-level) constants can be defined as CSS constants on the root element.
Re:Play with TailwindCSS in the Browser by holler on Friday June 10, 2022 @07:26PM (#31700466)
my thought exactly, sometimes I wonder when reading about tailwind... naming css classes has been a problem exactly 0 times in recent memory...
Re:Play with TailwindCSS in the Browser by dangerface on Friday June 10, 2022 @11:22AM (#31695432)
It seems like the main advantage of tailwind is that you don't have to learn how CSS cascading and specificity works, which is a fair advantage as most frontend developers I talk to don't even realise that specificity is a thing.

I don't see the advantage over inline style tho. I see abbreviations as a disadvantage as its just as fast to type background as it is bg but background is clearly more intelligible.

How do you deal with side effects for example I think bg-red is the brand red but some one has modified that class so it now has a border. You could prevent this with convention but then you have the same issues as using css with specificity and people not understanding the conventions around it.

I think its easier for every one to just force your frontend developers to just learn CSS and use it.

Re:Play with TailwindCSS in the Browser by tomtheelder on Friday June 10, 2022 @12:08PM (#31696069)
Tailwind is actually a lot like inline styles in certain ways. Whether that's a good thing or not depends on your use case. If you are using a component based framework it ends up, IMO, being way better and less complicated to use the abstraction you already have, your components, as your styling abstraction rather than trying to layer a second abstraction (the cascade approach) on top of it.

The biggest advantage over inline styles is that you are constrained. The idea is that you set up the primitives for your application's styling system: which colors are in use, which font weights, all the way to things like which border radii are valid. Your devs can then only use those.

You are correct that theoretically you can modify them to do anything, but in practice I find that people are extremely unlikely to violate the scheme (in ways like you described, adding a border to bg-red).

As for abbreviations? I think that's probably just eye of the beholder. Since you tend to add a lot of these to your HTML it helps it not get too ridiculously out of hand.

I spent years working with more traditional CSS schemes (including my all time least favorite, BEM), and it was pretty consistently a nightmare within the context of component driven applications. For a while now I've worked with tailwind and it feels like a massive step in the right direction.

I think it's one of those things that really doesn't make sense until you try it and feel the difference for yourself.

Re:Play with TailwindCSS in the Browser by teen on Friday June 10, 2022 @01:19PM (#31696948)
Tailwind has a lot of advantages if you read the documentation rather than conjecture about what you think it might do.
Re:Play with TailwindCSS in the Browser by bavila on Saturday June 11, 2022 @12:06AM (#31701824)
>...which is a fair advantage as most frontend developers I talk to don't even realise that specificity is a thing.

Really? I'm not sure I could take someone seriously if they called themselves a frontend developer and did not understand CSS specificity.

Re:Play with TailwindCSS in the Browser by blain_the_train on Friday June 10, 2022 @10:10AM (#31694475)
> 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.

Re:Play with TailwindCSS in the Browser by pythonaut_16 on Friday June 10, 2022 @10:12AM (#31694500)
So Tailwind with more steps
Re:Play with TailwindCSS in the Browser by xigoi on Saturday June 11, 2022 @05:36AM (#31703187)
Why not use actual inline CSS instead of that?
Re:Play with TailwindCSS in the Browser by calvinmorrison on Friday June 10, 2022 @11:39AM (#31695670)
> That's exactly what it is.

Which is why this is basically reinventing inline styles. With some shorthand.

How did we go from removing <u> and <b> to calling it <div class="bold" an improvement?

Re:Play with TailwindCSS in the Browser by tomtheelder on Friday June 10, 2022 @12:16PM (#31696171)
It's a lot like inline styles. The big advantage is that you create a design language with the helper classes, and then your devs are constrained to use it. No one can add a border radius of 11 if you only have utility classes for 8 and 16, or whatever. Historically you couldn't do that if you were using inline styles.

You could do it with a cascading approach, but if you're building a component based application (this is what Tailwind is really for) then you already have an abstraction for re-usability. Trying to layer another one on top usually results in a really difficult to reason about mess of interlacing components and style classes.

In short it's a way to use an inline-type styling approach, which is suitable for component based apps, without giving up the ability to constrain developers to a limited design language.

There are a TON of other benefits for utility classes over inline, but I think what I described is the biggest one (media queries, pseudo selectors, stylesheet caching for reduced page load, etc.)

> How did we go from removing <u> and <b> to calling it <div class="bold" an improvement?

You can still use <u> and <b> if you want to. Adding a utility bold class also works fine.

Re:Play with TailwindCSS in the Browser by pocketsand on Friday June 10, 2022 @08:26AM (#31693082)
It pushes you to componentize common UI elements. Feel bad to have long utility classes that look like <button class="bg-blue-700 border border-transparent hover:bg-blue-900 ring-2 ring-offset-2">. Change it to:

<submit-button>Submit</submit-button> using whatever tooling you prefer.

If you don't use this style, maybe you won't like it.

I've found it's a waste of time to extract classes for items that are not repeated. And putting utilities in components lightens your "master" CSS file and makes it a lot easier to work with CSS.

I've found that the "cascading" part of style sheets almost always breaks down in larger projects. Small components seem to avoid those breakdowns while allowing for reusability.

Re:Play with TailwindCSS in the Browser by the_other on Friday June 10, 2022 @09:15AM (#31693656)
> It pushes you to componentize common UI elements. Feel bad to have long utility classes that look like <button class="bg-blue-700 border border-transparent hover:bg-blue-900 ring-2 ring-offset-2">. Change it to: <submit-button>Submit</submit-button> using whatever tooling you prefer.

Even when you do that, you're still delivering the long, repetitive mark-up to the browser, rather than relying on the CSS engine to handle this for you. You're making the DOM MUCH MUCH heavier than it needs to be and ignoring the rendering engine that's optimised to handle this role. It seems wasteful all 'round. I confess I'm guessing here, and haven't tested it, but I suspect a simple, axiomic CSS file and simpler HTML file would produce faster rendering than Tailwind, and travel over the network faster.

Tailwind improves the developer experience at the expense of badly optimised code bloating and slowing the user experience. The developer experience benefits are debatable, too: I freaking hate using CSS toolkits and would much rather just write CSS or SASS bespoke to my apps. I have more control and can tailor a solution for the problem.

Re:Play with TailwindCSS in the Browser by jolux on Friday June 10, 2022 @10:00AM (#31694338)
> I confess I'm guessing here, and haven't tested it

Maybe you shouldn't make unsubstantiated claims like this then?

> Tailwind improves the developer experience at the expense of badly optimised code bloating and slowing the user experience.

I only say this because if your claims about performance are wrong, your comment seems to boil down to "I don't like CSS frameworks," which is fine, nobody's forcing you to use Tailwind.

Re:Play with TailwindCSS in the Browser by pocketsand on Friday June 10, 2022 @09:27AM (#31693851)
The overhead from processing class names is trivial.

Things like ads or heavy images actually slow the user experience. This type of thing isn't worth worrying about.

Re:Play with TailwindCSS in the Browser by nojs on Friday June 10, 2022 @11:32AM (#31695572)
> Even when you do that, you're still delivering the long, repetitive mark-up to the browser, rather than relying on the CSS engine to handle this for you.

The crazy repetition of classes gzips away though so there really isn’t any extra overhead.

Re:Play with TailwindCSS in the Browser by RyanGoosling on Friday June 10, 2022 @09:28AM (#31693869)
I wonder if this new element is compatible with a blind person’s screen reader. Any input?
Re:Play with TailwindCSS in the Browser by moray on Friday June 10, 2022 @08:53AM (#31693375)
That is called Class in CSS...
Re:Play with TailwindCSS in the Browser by aidos on Friday June 10, 2022 @09:18AM (#31693717)
This is all so played out now.

People that haven't used Tailwind come along and say, "this is silly, just use css". The people who have used it say, "you should try it, it's not what you think."

There are a bunch of subtle differences with Tailwind that make it quite a different experience.

Really, it's closer to inline-styles++ than anything else. The style only applies to the element you're styling. This is by design as it means you can change that one style without wondering what else you've broken across your app.

But you get variations that inline styles can't do (and aren't fun to do in css either): `text-green hover:text-red dark:hover:text-white` (interaction states, light/dark mode, responsive etc etc). This makes a huge difference when you're actually building this stuff.

Personally, from a DX point of view, I really like it. I find it faster than anything else when I'm building and it's easy to debug too; no need to fish for the styles, they're inline on the element I'm styling.

The biggest wart is the inability to functionally build up styles. For example, you have a bunch of js and you need to flip between several different colour states (say for an input that has "disabled | errored | valid | pristene"). There's no great way to force one of your classes to "win" because they're all just classes and the way they were added to the page will determine which border colour wins, for example.

Re:Play with TailwindCSS in the Browser by jonwinstanley on Friday June 10, 2022 @08:28AM (#31693102)
I totally thought this until I started using it on a full project. Six months in and I can't imagine writing traditional CSS or nested SASS classes anymore.

Combined with either Flexbox or CSS Grid, the speed with which you can put together a good looking web page is crazy fast.

Re:Play with TailwindCSS in the Browser by hbn on Friday June 10, 2022 @10:04AM (#31694387)
I thought it looked silly when I started my current job and saw it for my first time in their frontend applications.

Took a little bit to get the hang of, but once I did I was working WAY faster without the mental overhead of having to cross reference 2 text files (HTML + CSS) to build the same UI, keep them in sync, come up with names, etc. I iterate so much quicker, refactoring is so much faster cause you can literally just cut and paste a block of elements, throw them somewhere else, and they just render properly cause you brought the styles along with them. Screen size breakpoints make it so much easier to make responsive UIs. You get a free, built-in layout and color system.

It eliminated basically all the major painpoints of building UIs that I had before. I use it in all my personal projects now.

Re:Play with TailwindCSS in the Browser by nazka on Friday June 10, 2022 @10:04AM (#31694388)
Is it not because you forgot CSS and instead remember the tailwind names?
Re:Play with TailwindCSS in the Browser by jonwinstanley on Friday June 10, 2022 @10:23AM (#31694642)
Haha.

No, I still know CSS but I can’t imagine coming up with class names for everything then going to a different file to define rules. Feels so long winded and hard to keep on top of.

Re:Play with TailwindCSS in the Browser by andiareso on Friday June 10, 2022 @08:10AM (#31692931)
I thought the same thing before requiring to use it on an open-source project I was collaborating on.... it changed my mind within a few hours. It is a God send.

Like others have said, the selector logic is top-notch and not having to build your own styles is great as they are pre-defined. You can always modify the styles any way you want and add your own custom ones too.

It looks "gross", but it's very practical. If you follow the best standards for component sizing, you should never really have much of a problem with the styling getting in the way.

Re:Play with TailwindCSS in the Browser by yen223 on Friday June 10, 2022 @08:21AM (#31693043)
I've noticed this pattern with Tailwind specifically where people who look at it hate it, but people who tried it love it. I've tried it, and I like it.

This phenomenon encourages me to try something out before forming an opinion.

Re:Play with TailwindCSS in the Browser by isleyaardvark on Friday June 10, 2022 @03:35PM (#31698506)
It generally seems like the only objection is “it looks weird” whereas the people who use it invariably say it dramatically improves ease of development and prevention of bugs.
Re:Play with TailwindCSS in the Browser by mythz on Friday June 10, 2022 @10:10AM (#31694479)
If your project is setup to use Tailwind in watch mode where you can view your changes at every save, there's nothing quite as productive.

You get fast iterations without ever having to leave your markup to hunt down to find all the classes elements are using which uses their own structure & nomenclature, esp. if you need to support responsive layouts which every project implements differently that usually grows into some unmaintainable mess. With tailwind's utility classes it's all right there on the element, using intuitive prefixes and shorthand class names derived from the CSS properties it uses.

It's also the only framework I've used where you can copy markup from a number of different sources and it will look exactly the same as the preview where you got it from without it being distorted by the websites leaking cascading CSS styles.

Re:Play with TailwindCSS in the Browser by f3b5 on Friday June 10, 2022 @08:39AM (#31693220)
Tailwind is a thin wrapper for the people scared of CSS. I use Tailwind at work, and it opened my mind to the benefits of an "ugly" html layout with inline styling. However, being there now, I think that inline CSS offers the better "Tailwind experience" - CSS requires no setup, and learning it properly is a good investment for the future when Tailwind, like so many other frameworks, will inevitably end up on the frontend dumpster fire.
Re:Play with TailwindCSS in the Browser by tomtheelder on Friday June 10, 2022 @12:26PM (#31696273)
Inline CSS has a few HUGE drawbacks compared to Tailwind, but I think the biggest by far is that your devs are totally unconstrained in what they can do for styling. You're forced to rely solely on convention to not, for example, violate your color palette, or use the wrong border radius, or the wrong padding value. For a small app with a small team and no concrete design system that's not a big deal. At scale that is absolutely massive.

A few of the other advantages of Tailwind: - reduced noise in the markup compared to raw inline styles, with the underlying styles getting cached by the browser - utility classes can contain multiple properties that should always go together - media queries!

You should learn what CSS is actually doing as well, but realistically Tailwind is, like you said, a pretty thin wrapper on CSS. Learning Tailwind usually just means learning CSS, with some different property names.

Re:Play with TailwindCSS in the Browser by stefanfisk on Friday June 10, 2022 @09:15AM (#31693660)
how would you use media queries or pseudo selectors in inline CSS?
Re:Play with TailwindCSS in the Browser by megaman821 on Friday June 10, 2022 @09:43AM (#31694078)
I was about to say, if anything it shows there is demand for the style tag to handle pseudo selectors. Setting up some CSS variables on the root and accessing them through the style tags would provide most of the benefit of Tailwind.
Re:Play with TailwindCSS in the Browser by f3b5 on Friday June 10, 2022 @09:49AM (#31694168)
Good point, I don't know of any way of doing that inline. So that's definitely a good convenience function in Tailwind!

My lived approach to inline vs. not-inline is: why not both? Inline is great for prototyping, and for edge cases, like specific margins for wrapper divs. Where CSS classes really shine is when it comes to mature / often used components.

Re:Play with TailwindCSS in the Browser by pcthrowaway on Friday June 10, 2022 @01:03PM (#31696762)
Pseudo elements as well
Re:Play with TailwindCSS in the Browser by madeofpalk on Friday June 10, 2022 @08:00AM (#31692827)
I'm with you. I'm pretty into neat experimental frontend + css stuff, and I'm baffled by how passionate Tailwind's fans are. It always feels like there's something I'm missing.

In all fairness, I've never actually tried it.

Re:Play with TailwindCSS in the Browser by christophilus on Friday June 10, 2022 @08:10AM (#31692935)
> In all fairness, I've never actually tried it.

I was of your opinion until I tried it. Been using it for over a year on my current project, now.

I recently built a little prototype without using Tailwind, and man… I didn’t realize how big a quality of life improvement Tailwind is until I stopped using it. It’s really hard to imagine going back.

Edit: I’ve been building websites since 2000, and know CSS quite well, and hope to never write much CSS again.

Re:Play with TailwindCSS in the Browser by chrisshroba on Friday June 10, 2022 @08:18AM (#31693020)
Agreed - they even include almost at the top of their homepage [1] a quote from the creator which includes: "If you can suppress the urge to retch long enough to give it a chance, I really think you’ll wonder how you ever worked with CSS any other way."

[1]: https://tailwindcss.com/

Re:Play with TailwindCSS in the Browser by rozenmd on Friday June 10, 2022 @08:19AM (#31693021)
> In all fairness, I've never actually tried it.

That's what you're missing. Try it.

Re:Play with TailwindCSS in the Browser by danielvaughn on Friday June 10, 2022 @08:08AM (#31692904)
You should give it a shot, but IMO what makes it worth it is the Tailwind Intellisense plugin. I can design an element in just a few keystrokes, it's amazing.
Re:Play with TailwindCSS in the Browser by rjknight on Friday June 10, 2022 @08:08AM (#31692907)
You have to learn the browser layout model, yes - you need to know what flexbox is, or how padding or transforms or line height works. But Tailwind provides sensible defaults for how those things are applied, which removes a lot of potential for screwups. It also removes most of the potential for badly “architected” CSS, where you accidentally end up with a set of classes that don’t compose together in a predictable fashion. This greatly lowers the cognitive burden, which helps when collaborating with others or even with your past and future self.

I get that it is aesthetically ugly, but if you can stop caring about that then you might find that it’s better on most other dimensions.

Re:Play with TailwindCSS in the Browser by agloeregrets on Friday June 10, 2022 @08:05AM (#31692871)
> 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.

In my experience, tailwind is pretty close to the real CSS properties. What I found to be wonderful and freeing about it is that it stops the middle step of engineering and naming classes and naming elements with class names and let's you just do styling. There's also a really great plugin for VS code that adds intellisense. Personally I found the modifiers that allow you to target pseudo selectors like :hover to be a superpower. I totally understand the other side of the argument though. It's a lot.

Re:Play with TailwindCSS in the Browser by jonwinstanley on Friday June 10, 2022 @08:31AM (#31693136)
CSS has special syntax for media queries, hover states, dark mode etc. If anything, once you are into it Tailwind is far more "guessable".
Re:Play with TailwindCSS in the Browser by agloeregrets on Friday June 10, 2022 @08:39AM (#31693217)
Correct, but wring all of those can get confusing and adding a single psudoselector syntax for something is at least a few lines and figuring out how to organize css. Scss is definitely better for this but even then it's a bit nebulous remembering which selector has the states in them.
Re:Play with TailwindCSS in the Browser by MarquesMa on Friday June 10, 2022 @12:07PM (#31696056)
> and then scatter that all over your markup

This is not how you use Tailwind. Back then there was no such concept as component, so people need to write CSS classes to encapsulate and reuse styles.

Now Components are everywhere, and when you write components and CSS classes at the same time, you're non-obviously duplicating structures (Write components, then write classes corresponding that component).

In essence, Tailwind (or styled components and such) makes component mechanic as your single source of abstraction.

Re:Play with TailwindCSS in the Browser by enobrev on Friday June 10, 2022 @08:31AM (#31693129)
I wasn't a big fan of the idea before trying it and then I tried it for a small project. I get the appeal, but as the project grew in complexity, I found I disliked managing tailwind

But the experience while writing the code is pretty excellent. It made me realize that what I really want (personally) is to have my css inlined in my editor when writing / editing it, and otherwise remain out of the way in my css file.

Re:Play with TailwindCSS in the Browser by aidos on Friday June 10, 2022 @08:51AM (#31693356)
Oooo. That’s an interesting idea. Being able to toggle className to be `className=“…”` in vim.

Would be interesting to see what an experience of being able to toggle between classless and class-only jsx looked like.

Re:Play with TailwindCSS in the Browser by vlod on Friday June 10, 2022 @01:32PM (#31697092)
That would make it more appealing for me. Just saw this proposal:

"Add the option to hide class attribute in vscode plugin" https://github.com/tailwindlabs/tailwindcss/discussions/7922

Re:Play with TailwindCSS in the Browser by divan on Friday June 10, 2022 @09:45AM (#31694120)
Building UIs with typesetting engine and bunch of styling classes is fundamentally wrong. CSS is broken by definition. Tailwind makes it a bit less broken on practice.
Re:Play with TailwindCSS in the Browser by sph on Friday June 10, 2022 @08:28AM (#31693100)
The usual answer, however trite, is "don't knock it till you've tried it."

I haven't found a convincing explanation of why exactly this is better until I've used it in a project, and since then I'm completely sold. The semantic CSS concern separation pipe dream has always been snake oil in real projects.

Long live Tailwind.

Re:Play with TailwindCSS in the Browser by danielvaughn on Friday June 10, 2022 @08:51AM (#31693354)
I ended up deleting like 30% of my React components after switching to Tailwind, because suddenly they just felt like unnecessary overhead. Tailwind FTW.
Re:Play with TailwindCSS in the Browser by jonwinstanley on Friday June 10, 2022 @08:40AM (#31693241)
Also - no more constant switching between the HTML and the corresponding style rules
Re:Play with TailwindCSS in the Browser by cmehdy on Friday June 10, 2022 @10:04AM (#31694391)
I do not know much about CSS but Tailwind was very straightforward, and through it I got to learn things in CSS which weren't made obvious before. It's funny that you use the terms "tedious mess" because that's exactly how I feel about CSS without it. Handling screen sizes, print, colors, and simple layouts.. all that seems way too annoying to do in pure CSS to my non-frontend-dev mind, and trivial to do with Tailwind.
Re:Play with TailwindCSS in the Browser by peterkelly on Friday June 10, 2022 @08:26AM (#31693079)
Any time spent learning tailwind is much better invested in learning plain CSS, since it's basically just syntactic sugar for style attributes. And learning CSS itself will be useful for many years to come, well beyond the lifetime of any given framework.

The browser's built-in CSS support is the framework, I don't understand why people try to build things like this on top of it unless they're adding real value.

Re:Play with TailwindCSS in the Browser by brightball on Friday June 10, 2022 @10:11AM (#31694484)
But it does add real value.

Aside from creating a standard naming scheme for your style guide, they also simplify specific CSS tag features by ensuring they can be consistent across browsers without you having to tweak each style.

Outside of that, they acknowledge that you're not going to use custom CSS tags that often because 9 times out of 10 you're going to style something in one place in a template and your programming language will repeat it for you...so there's no real value to creating a dedicated class.

Another that I've found over the lifecycle of a project is that developers forget what CSS is where and end up simply creating new classes for things that they need rather than trying to reuse existing ones...which leads to your CSS growing constantly over time. With Tailwind I rebuilt my entire personal site, brightball.com and ended up with 20 lines of custom CSS. This after restyling the entire site and making it responsive. And I was able to do all of it in an afternoon without ever having even made a responsive site before.

What they've done is created "Rails for Style Guides" and it works beautifully. The Refactoring UI book (fast read) from the authors of Tailwind goes into the importance and reasoning for everything they do and it makes absolutely perfect sense.

https://www.refactoringui.com/

Re:Play with TailwindCSS in the Browser by pocketsand on Friday June 10, 2022 @08:30AM (#31693115)
It's really not just syntatic sugar for style.

It's a design system as well as a set of utility classes. Consider the difference between

<span style="color: #cccccc">Gray text</span> and <span class="text-gray-700">Gray text</span>

In the former, you can't just redefine what gray means. You've hard set it to a value you need to keep track of and keep consistent. On the right, you can configure what "700" means, switch between a cool gray or a blue gray, etc.

Re:Play with TailwindCSS in the Browser by jakelazaroff on Friday June 10, 2022 @09:43AM (#31694076)
So use a custom property instead (don’t use inline styles tho):

    <span style=“color: var(--text-gray-700)”>Gray text</span>
Or use Sass or something. This problem has been solved for like 15 years.
Re:Play with TailwindCSS in the Browser by hbn on Friday June 10, 2022 @10:16AM (#31694533)
I want the styles to be in the template though, because I don't want to bounce back and forth between 2 files when designing a single UI. And it's not just inline styles, there's some things Tailwind can do that a style tag can't. Such as screen size breakpoints.

Here's how to make a div have 0.5rem of left/right padding on mobile, and 2rem on any screen larger:

    <div class="px-2 sm:px-8">
I'd much rather do this than mess with CSS's horrible media query syntax myself. And when I come back to this later, I don't have to cross-reference between (probably badly named) classes across 2 files to figure out how that div behaves.
Re:Play with TailwindCSS in the Browser by jakelazaroff on Friday June 10, 2022 @10:43AM (#31694911)
Okay, but now we’re back to Tailwind being back to syntactic sugar for styles (you can definitely put media queries in a style tag).

I disagree with your preference; all the classnames are not easily parseable and obscure the markup, and I much prefer the CSS media query syntax. But that’s, like, just my opinion, man. If you like it better, don’t let me stop you!

Re:Play with TailwindCSS in the Browser by skttl on Friday June 10, 2022 @11:31AM (#31695555)
>(you can definitely put media queries in a style tag)

How?

Re:Play with TailwindCSS in the Browser by jakelazaroff on Friday June 10, 2022 @11:47AM (#31695781)

    <style>@media (min-width: 100px) {}</style>
Re:Play with TailwindCSS in the Browser by azemetre on Friday June 10, 2022 @10:38AM (#31694829)
This is what tailwind does already. Colors are defined as design tokens in a config file:

https://tailwindcss.com/docs/customizing-colors#color-object...

Utility CSS is by far my favorite way to write CSS, especially in teams. It allows you to extract out multiple classnames that encapsulate all styles into a single classname.

Why would you use Sass when plain CSS does the job better? Tailwind is just normal CSS, all the build steps are ways of making your stylesheets more efficient and removing dead code but it's all still CSS no preprocessor necessary.

Re:Play with TailwindCSS in the Browser by my80thaccount on Friday June 10, 2022 @10:59AM (#31695131)
Those are both just opaque values, if you wanted to gsub them it would be exactly the same.
Re:Play with TailwindCSS in the Browser by likortera on Friday June 10, 2022 @10:55AM (#31695076)
Because most people worry more about maintainability, ease of writing, modifying, performance, resulting bundle size, tooling, consistency, etc and very few about "how it looks".

Everyone that complains about tailwind is because they didn't use it yet.

Yes, looks weird at first. That's not everything that matters.

Re:Play with TailwindCSS in the Browser by RyanGoosling on Friday June 10, 2022 @09:26AM (#31693848)
I use Bootstrap components. I’ll use Bootstrap utility classes (essentially what TailwindCSS is) for some one-off margin bottom (“mb-3”). Using TailwindCSS alone seems bad to me. Using TailwindCSS is pointless when using Bootstrap (Bootstrap Utilities)
Re:Play with TailwindCSS in the Browser by jononomo on Friday June 10, 2022 @09:12AM (#31693611)
I had the exact same opinion after working with tailwind for a week, but then, after a couple more weeks, I fell in love and decided that this is what CSS should have been from the start.
Re:Play with TailwindCSS in the Browser by mightybyte on Friday June 10, 2022 @08:13AM (#31692971)
Completely agree with you. I greatly prefer something like PicoCSS (https://picocss.com/) which tries to use plain HTML5 as much as possible.
Re:Play with TailwindCSS in the Browser by clementmas on Friday June 10, 2022 @08:37AM (#31693185)
Interesting. I like the idea of clean HTML. It's probably great for small projects but I'm not sure it would scale for bigger applications.
Re:Play with TailwindCSS in the Browser by mightybyte on Friday June 10, 2022 @09:30AM (#31693902)
In my experience with larger applications no matter what CSS framework you use you eventually want to ditch it and move to fully custom CSS. Starting with this kind of a clean HTML base makes that easier IMO.
Re:Play with TailwindCSS in the Browser by tomtheelder on Friday June 10, 2022 @12:29PM (#31696305)
That was my experience... until I used Tailwind. The thing is, it basically is fully custom CSS. It's just inline since you already have a re-usability abstraction if you are building a component based application. It's not even really a CSS framework at all. It's infinitely less prescriptive than what you usually see.
Re:Play with TailwindCSS in the Browser by clementmas on Friday June 10, 2022 @08:30AM (#31693123)
I gave it a shot and now I like it. I don't have to add classes to my HTML and separate my CSS. I find it more maintainable. The built-in config and colors are also quite good.
Re:Play with TailwindCSS in the Browser by danielvaughn on Friday June 10, 2022 @08:53AM (#31693379)
I nearly always use the built-in config. Though oddly enough, I don't like the new colors (>=3.0 I think), because there's just too many of them now. What I appreciated was the restricted option set; now it just feels like I need to worry about design decisions, which is what Tailwind let me not worry about.
Re:Play with TailwindCSS in the Browser by rajasimon on Friday June 10, 2022 @10:20AM (#31694589)
I have eight years in full stack development experience and after tried four times Tailwind a chance now I am back to Bulma and going steadily.
Re:Play with TailwindCSS in the Browser by seabea on Friday June 10, 2022 @08:22AM (#31693048)
I'm really tired of needing to wade through these sort of comments. This is not a unique criticism.

If you don't don't get it, either try it out or move on.

These comments add no value to the conversation.

Re:Play with TailwindCSS in the Browser by rco8786 on Friday June 10, 2022 @09:51AM (#31694206)
My apologies for having a discussion on a discussion forum