Re:Don't use Tailwind for your Design System
by blowski on Wednesday January 11, 2023 @06:06AM
(#34337183)
In general, framework owners _want_ you to become tightly coupled to the framework, whereas as a user you want to be able to move away from it more easily. I think this conflict of interests is behind recommendations like this, rather than sound technical reasons.
Re:Don't use Tailwind for your Design System
by abujazar on Wednesday January 11, 2023 @07:49AM
(#34337800)
Why would framework owners want you to become tightly coupled to the framework? They're basically just offering a set of solutions that come with some tradeoffs, but they don't intentionally create problems for their users.
Re:Don't use Tailwind for your Design System
by blowski on Wednesday January 11, 2023 @08:39AM
(#34338263)
* * *
Re:Don't use Tailwind for your Design System
by satvikpendem on Wednesday January 11, 2023 @06:08AM
(#34337195)
Sure, I've already moved onto CSS in TS solutions like vanilla-extract above though, I like my typechecking in my CSS.
Re:Don't use Tailwind for your Design System
by di4na on Wednesday January 11, 2023 @06:58AM
(#34337492)
The real answer is in CSS developing a proper supported way to do mixins.
I keep being surprised that noone bring this up in these discussions.
Re:Don't use Tailwind for your Design System
by presentation on Wednesday January 11, 2023 @08:54AM
(#34338446)
I do it with emotion (CSS in JS), specifically NOT using styled components and instead using the CSS prop which allows for composing styles more naturally, and it works great. Never felt a need to get my team on Tailwind since it’s already super productive with the right set of mixins.
Re:Don't use Tailwind for your Design System
by di4na on Wednesday January 11, 2023 @07:17PM
(#34347136)
I get you, the problem is that CSS in JS is simply not possible for the vast majority of web developers out there that work on a site render framework that is not JS ;)
I think this is the main reason why Tailwind took off so fast. The frontend tooling world forgot the majority of its users.
Re:Don't use Tailwind for your Design System
by tekkk on Wednesday January 11, 2023 @07:25AM
(#34337628)
Yeah I don't understand what the other solution would be. If you want to have reusable styles, eg "btn" class with all your defaults @apply is the obvious choice. Otherwise you'll end up with similar gargantuan CSS class spagetti and/or have to abstract away some generic components because handling the classes is just too much.
Re:Don't use Tailwind for your Design System
by mvf4z7 on Wednesday January 11, 2023 @07:42AM
(#34337734)
I was under the impression that you create a button component and apply the atomic styles in that component. That way you don’t don’t need a “btn” class, you just use the Button component anywhere you need a button.
Re:Don't use Tailwind for your Design System
by tekkk on Wednesday January 11, 2023 @08:42AM
(#34338294)
You could do that but many of the minor stylings might not warrant a component, like a specific hover effect. For quick prototyping though it just is way more convenient to not to constantly break apart small html snippets into their own components.
Re:Don't use Tailwind for your Design System
by lawn on Wednesday January 11, 2023 @08:10AM
(#34337975)
This assumes you only have one button class, while you might want to reuse several that have minor differences.
Re:Don't use Tailwind for your Design System
by eckmLJE on Wednesday January 11, 2023 @08:59AM
(#34338502)
What if you need to render your button component as an anchor element? Or as a div with role="button"? You will want to abstract your button styles somehow so that they can be shared between these three (or more) use cases. Sure you could experiment with using a polymorphic `as` prop to render your button component as any element, but if you're using TypeScript that can get complicated quickly, especially if you're then trying to use that component in conjunction with something like next/link or react-router/link. It's simpler to strip default styles from all your components, and then have a button class to add to any element you want to appear as a button.
BUT, then what if you want to add some kind of special behavior to your button that involves subcomponents, e.g. a loading state that conditionally renders a spinner inside the button? Or you want to provide convenience props like rendering an icon before or after the button text? Then a class is not enough.
If you're building a design system/component library, none of these options are simple and there are always tradeoffs.
The fact is @apply is there and if we're using it and there's enough push-back, I don't see why the Tailwind team wouldn't listen to that or create a workable upgrade path for those who wish to continue to use it.
So use the tools you have - don't avoid it just because the core team dislike it. They can't remove it in the version you have installed today (unless they have some magical way to reach into your computer/server)