@apply directive not working anymore? #17795
-
Hello! I have a fresh vue3 installation and added tailwind according to the "vite" installation guide: https://tailwindcss.com/docs/installation/using-vite Adding tailwind classes in the template elements directly works just fine but I'm used to use the @apply directive within the style section of my vue templates. The moment I'm using sass in my style block, the @apply directive does not work anymore. However, sass itself works. As an example: ❌ @apply with sass does not work
✔️ @apply works without sass
✔️ sass works without @apply/@reference
Note: Official docs about using @reference first so I can use @apply inside the style block package.json:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Tailwind is not compatible with Sass. As an aside, Adam Wathan (creator of Tailwind) does seem to advocate avoiding |
Beta Was this translation helpful? Give feedback.
-
Mhhm... I see... That sass thingy is new, it worked before v4. I really can't wrap my head around having an element with like 1-20 classes inside my markup. I find it not only ugly but also somehow harder to maintain.. especially when having like multiple different rules for sm, md, lg, xl for the same element. There I used to do:
Which maybe looks "longer" than having: While my markup simply had one class per element that was named properly and I knew just by the class name, what this element is supposed to be. But when I see some div element with like 12 different rules, I might not know that right away what this element is supposed to do. |
Beta Was this translation helpful? Give feedback.
In this case, I split class names up into multiple lines like:
If you reuse this group a lot, you could refactor this string to a constant and use it elsewhere:
Or perhaps abstract it to a CSS variable: