Live data from Hacker News

Working with Tailwind CSS every day for 2 years

themosaad.com

201–210 of 215 posts

Re: Working with Tailwind CSS every day for 2 years

#201
post #56

Earlier quoted context omitted.

I'd be very surprised if there are many devs with a deep understanding of CSS using Tailwind.

I'm sorry but this is just a crazy thing to say. You cannot use Tailwind without understanding CSS. Take the example `block`. Ok so a junior FE dev is supposed to use this class without understanding CSS? How?! It just maps to `display: block;`. It hides literally none of the complexity.

I don't agree with the parent poster, but I would say that there is a large portion of frontend devs that "don't understand css" at a very deep level. For every 1 that does there are a good 9 or 10 that just get enough to get by.

That said -- you need to know the average amount of CSS to be successful using tailwind.

Re: Working with Tailwind CSS every day for 2 years

#203
post #85
post #68

Earlier quoted context omitted.

If you dislike walls of class names, you could consider using Tachyon's style abbreviations like we do in Truss: https://github.com/homebound-team/truss

From that link: ` ... ;` That must be one of the most horrid things I've ever seen done to CSS.

Yep, that looks like what a few seconds of my vim typing looks like but tossed into source code. Ill take the wall of tailwind any day over that.

Re: Working with Tailwind CSS every day for 2 years

#204

A lot of people I respect really like Tailwind, but I just don’t get it. Seems like you end up with walls of classes because you don’t name your compositions, and thus your design system doesn’t actually live anywhere. If you have a standard box in your design system with a certain padding, spacing, font size, and so on, are you really going to write out all its constituent properties every time you use it? How do yo…

I think the usual solution here is just to make your standard box a component, as opposed to using a div with a class. Then if your design system changes, you just change the wall of tailwind classes in that single component file.

[deleted]

Re: Working with Tailwind CSS every day for 2 years

#205

A lot of people I respect really like Tailwind, but I just don’t get it. Seems like you end up with walls of classes because you don’t name your compositions, and thus your design system doesn’t actually live anywhere. If you have a standard box in your design system with a certain padding, spacing, font size, and so on, are you really going to write out all its constituent properties every time you use it? How do yo…

I think the usual solution here is just to make your standard box a component, as opposed to using a div with a class. Then if your design system changes, you just change the wall of tailwind classes in that single component file.

And now you are inventing your own Theme UI or Emotion

Re: Working with Tailwind CSS every day for 2 years

#206

Earlier quoted context omitted.

> the way it's made, via object properties, enforces compliance to the design system. The link literally has this: ``` export const className = style({ display: 'flex', flexDirection: 'column', selectors: { '&:nth-child(2n)': { background: 'aliceblue' } }, '@media': { 'screen and (min-width: 768px)': { flexDirection: 'row' } } }); ``` Which is indistinguishable from any other CSS-in-JS which has hundreds of these one…

Sorry, could you reformat your code? I can't read this well.

Sorry, I keep forgetting that HN is weird with line breaks

Re-typing/re-quoting:

--------

The link literally has this:

    export const className = style({
      display: 'flex',
      flexDirection: 'column',
      selectors: {
        '&:nth-child(2n)': {
          background: 'aliceblue'
        }
      },
      '@media': {
        'screen and (min-width: 768px)': {
          flexDirection: 'row'
        }
      }
    });
Which is indistinguishable from any other CSS-in-JS which has hundreds of these one-off things scattered everywhere. With a theme somewhere exposing another hundred or so variables of varing quality. And all these solutions basically converge on Tailwind (or other utility-first CSS approaches):

    export const hero = style({
      backgroundColor: vars.color.brandd,
      color: vars.color.white,
      padding: vars.space.large
    });
is nothing more than `bg-brand color-white p-4`

But TypeScript support is definitely nice.

----

Re: Working with Tailwind CSS every day for 2 years

#208
post #207

Haven't seen it mentioned, but if you like Tailwind, maybe take a look at UnoCSS: https://github.com/unocss/unocss It is like the next evolution of Tailwind. See this blog post for full explanation: https://antfu.me/posts/reimagine-atomic-css

Also, well looks like a lot of people here don't like this style of CSS coding.

As someone who's been writing HTML since Netscape days, I find Tailwind/UnoCSS plus a modern web framework (React/Vue/Solid JS) the most productive way to develop websites ever.

The main thing is in a single React or Solid JS component, you can have all the code, html and styling for a component in one file or most of the time in one function even.

No more having to deal with jumping around between template and css files, having to search for where a class or a styling is defined, or trying to figure out how to structure or even name the css classes. No more having to make decisions like "Should I put this styling in this class or that class or in a classless selector."

For me, it just saves too much time to not use.

I was skeptical at first, but once I started using it, I could never go back.

Re: Working with Tailwind CSS every day for 2 years

#209

A lot of people I respect really like Tailwind, but I just don’t get it. Seems like you end up with walls of classes because you don’t name your compositions, and thus your design system doesn’t actually live anywhere. If you have a standard box in your design system with a certain padding, spacing, font size, and so on, are you really going to write out all its constituent properties every time you use it? How do yo…

I'm very sceptical of class-based CSS solutions because I had "do it semantically" drilled into me when learning it.

However I think I'm starting to come around because it finally clicked that modern web programming already abstracts styles on another level, as components.

So instead of repeating yourself, you create something like a StandardBox component and it brings all of its styles.

It still doesn't look or feel very elegant to me, but this seems to be the compromise most web developers are willing to make. Changing the theme seems to be mostly done through variables.

Re: Working with Tailwind CSS every day for 2 years

#210
The problem 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.

Post reply on HN