After V4 upgrade I am confused on how to use @apply with custom css #17443
-
Hello, When I used V3, I could define those CSS (although with different syntax) in tailwind.config.js, inside "theme" block. I also tried to put it now inside the @theme, but probably I'm not getting the right syntax. Can somebody advise? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You'd need to register those class names with @utility bg-size-200 {
…
}
@utility bg-pos-0 {
…
}
@utility bg-pos-100 {
&:hover {
…
}
} Alternatively, you could forgo them altogether: @utility btn-calculate {
…
background-size: …;
background-position: …;
&:hover {
background-position: …;
}
} Or better yet, use your templating system: -<button class="btn-calculate">
+<CalculateButton> <button class="… bg-[size:200%_200%] bg-left-top hover:bg-right-bottom">
{{ content }}
</button> As an aside, Adam Wathan (creator of Tailwind) does seem to advocate avoiding |
Beta Was this translation helpful? Give feedback.
-
Thanks!!! went with this: |
Beta Was this translation helpful? Give feedback.
You'd need to register those class names with
@utility
so that Tailwind knows about them:Alternatively, you could forgo them altogether:
Or better yet, use your templating system:
As an aside, Adam Wathan (creator of Tailwind) does seem to advocate avoiding
@apply
: