top | item 34336798

(no title)

ls15 | 3 years ago

> @apply is the directive that Tailwind recommend to extract repeated utility patterns. Since it's a static definition, you would only abstract those lists into a CSS file. I don't want to get into much details about it, but it does not solve the problems mentioned before.

I would like to know why @apply does not solve the issues in the author's opinion. This is exactly the part where the author should have gone into details.

discuss

order

nonethewiser|3 years ago

Probably the same as this reasoning:

> Even that this snapshot of code-UI is doable in Tailwind, at some level of those components you will find a layer with a bunch of classNames that you need to parse in your head in order to imagine the UI.

So he would probably say that @apply just abstracts away the problem but it still exists somewhere that you'd need to parse through to understand the styling.

But this doesn't resonate with me. This isn't avoidable in any scenario. Either you have a styled component with a bunch of css-in-js, or a bunch of css, or a bunch of utility classes. In all scenarios there is an implementation that you have to parse. Which basically means it has nothing to do with @apply and everything to do with css vs. utility classes.