News for hackers. Stuff that matters.
Re:Tailwind UI by have_faith on Wednesday February 26, 2020 @10:56AM (#22424082)
> Tailwind has lots of classes, but each class does one thing

I think this masks a lot of complexity that you have to manage when taking on this approach. And it's not because the approach is good or bad, more what it is or isn't suited for.

The example on the homepage is very slickly presented, but the end result markup is extremely verbose. If I have a Card component, I would like to update them all at once when needed which is what css classes are generally good for. I find BEM naming conventions much more friendly to come back to than markup full of miniature class names.

Re:Tailwind UI by nicpottier on Wednesday February 26, 2020 @01:00PM (#22425475)
I had a similar recoil to this approach and then I tried it, and I think they are actually onto something.

Yes, you may have more than one card in your system, but in all likelihood you aren't repeating the HTML for that card more than once, rather you have it in a template of some kind which is called. So while you may have more than one card on your site, you probably don't have the template for it defined more than once. (at least ideally you don't)

For those cases where you do want to extract that code, Tailwind makes that easy to do.

Tailwind is a weird thing and like I said I really thought it was insane at first. But after rewriting a site in it in a few days I have to say it is better than the standard semantic CSS by a mile.

Re:Tailwind UI by jeffschofield on Wednesday February 26, 2020 @11:33AM (#22424493)
The recommended way to handle components is by using template partials or JS to manage your card component rather than CSS classes. [1]

Though, you can still use BEM with TailwindCSS through the @apply directive. Adam calls the directive a kind of "trick" to get more devs on board with utility-first but it does help a lot of you're used to reasoning about CSS with BEM.

[1] https://tailwindcss.com/docs/extracting-components

Re:Tailwind UI by andrei_says_ on Wednesday February 26, 2020 @11:14AM (#22424281)
My sense is this is for people who do not know css to the level needed to implement BEM. Also, it replaces the cost of knowing css and naming things (class names) with the cost of learning the tailwindcss classes.

I will stick to BEM + colors and sizes maps because this feels almost like using the style tag on each element.

For non-css expert engineers writing spa components, tailwind can be useful.

I can also see that it’s not trivial to mix tailwindcss and scss processors so it’s a no for me.

It has the benefit to limit spacing and color sets to presets but I already do this in my BEM codebase.

Re:Tailwind UI by smnplk on Wednesday February 26, 2020 @11:28AM (#22424440)
what is BEM?
Re:Tailwind UI by akie on Wednesday February 26, 2020 @11:33AM (#22424497)
Block-Element-Modifier, a way to structure your CSS. http://getbem.com/
Re:Tailwind UI by marc_io on Wednesday February 26, 2020 @11:13AM (#22424275)
You can work with components too, just use the @apply directive. https://tailwindcss.com/course/composing-utilities-with-appl...
Re:Tailwind UI by city41 on Wednesday February 26, 2020 @11:47AM (#22424672)
It’s common, even expected, to extract that card into a component of some kind (React, web components, mustache template, etc) so you still only have to update the css once.
Re:Tailwind UI by ec109685 on Wednesday February 26, 2020 @12:28PM (#22425125)
Your components often get bloated since you have to account for subtle business logic differences between views.
Re:Tailwind UI by stefanfisk on Thursday February 27, 2020 @12:19AM (#22430741)
Isn't that what the container/component split is for? Presentation logic in a container, markup and styling in a component. If you need to reuse the same visual component in logically different contexts you create a new container that mangles the props as appropriate.
Re:Tailwind UI by ec109685 on Thursday February 27, 2020 @01:51AM (#22431209)
Yeah, you can. I've just seen this result in really complicated components. Other styles of CSS naturally separate presentation from html markup generation, so the cost of forking and specialized components is much lower.
Re:Tailwind UI by jp_sc on Wednesday February 26, 2020 @12:35PM (#22425187)
Sure, until, you need a variation on that card for some elements, and add some other tailwind classes to the HTML to do it. Everything seems to work fine for a while.

Then you update the styles of the card again but the new styles clash with the ones in those tailwind classes and you end with broken styles in some elements.

Mixing components and utility classes is a recipe for future chaos.

Re:Tailwind UI by city41 on Wednesday February 26, 2020 @12:44PM (#22425279)
How is that different from any other css? I'd argue any css solution would have this problem with components.

edit: thinking more, you can override classes. So yeah, maybe utility/atomic classes are not as effective here.

Re:Tailwind UI by rojoca on Wednesday February 26, 2020 @02:02PM (#22426058)
No, you just create a new card component and adjust the tailwind classes on it.

Or, if it is a minor change, then conditionally include / exclude a small subset of tailwind classes.

The point is to not write your own CSS, you only use tailwind classes. In this way you can look at the template for each of your components and reason about / edit their style and layout easily.