Hacker News new | ask | show | jobs
by solumunus 1294 days ago
But you can create custom classes using @apply. If you're doing that alongside using it in components then it's incredibly DRY and far more efficient than anything else I've ever used in the last 20 years.
2 comments

What's the difference between custom tailwind classes and... regular CSS?
Not much.

Tailwind's @apply just lets you apply Tailwind design tokens to CSS classes. It's useful for keeping designs looking consistent if you're already heavily invested in Tailwind. This is probably not much of an advantage unless you're working at a very large organization with many teams and web properties. And there are other CSS-native ways of enforcing design token consistency without Tailwind too. Open Props is a good example (https://open-props.style/).

@apply is also a great lazy way to just slap a string of Tailwind classes from mark-up into a class. It doesn't sound proper but it works in the context of iterative development.

Or Bootstrap, etc. This is why we didn't end up using TW for a large production app. It's really cool, but realized we were just ending up re-creating something like Bootstrap components using TW @apply.
Once familiar, it's far quicker to read, write and reason about than raw CSS, in my experience.
Absolutely, I love @apply for this reason. But just look at tailwind's website, they don't exactly present this front and center, so I read their site as though they don't exactly prescribe the usage of @apply like you or I would.

but tangentially to this, that's why I like tailwind, its really not all that prescriptive but a tool that speeds up my development un-equivocally more than Sass ever has.