by yawnxyz · 3y ago · 0 comments
What I mean is something like this:
.Card {
@apply p-2 bg-gray-100;
&.--red {
@apply bg-red-200;
}
}
Now, the docs (and the founder) are vehemently against implementing Tailwindcss like this, but it makes the code really readable and reusable. Adding "@apply ___" in my SCSS is much more compact than writing out full CSS, and I think much more readable. Plus, I get to apply whatever CSS that are out of scope of Tailwind. Win win.If you're just going to stick the tail wind classes in a class like this, why bother? just use css vars.
Basically its tailwind without all the classes, and without apply, in pure CSS variables
The problem I'm solving for is NOT having to find/replace every tailwind-spam across several projects/components/frameworks if I want to add a new "color" property to a .Card, or change the padding, or whatever. I just change the source utility, then link to the file (with Git / package.json linking), so the one change can be applied across projects.
If I followed what the founder and docs said, I'd have to spend every waking hour find/replacing text across all my projects.