Hacker News new | ask | show | jobs
by francislavoie 3 hours ago
Using @apply defeats the entire purpose of Tailwind. The point of it is to localize styling alongside the markup. If you're using @apply then you're constantly context switching from your markup to your CSS files while working.

There's plenty of ways to manage the bevy of classes you need. First step is making use of components to deduplicate stuff. Then in those components, use a library like class-variance-authority aka "cva()" which allows you to set up complex named presets for your components (like size="small" or color="primary" and things like that).

1 comments

I use @apply in quite a few projects, mainly because I like the defaults in tailwindcss. I know it defeats the point of tailwind, but I find that it works nicely when using BEM.