Components are not working with utilities classes #15444
-
What version of Tailwind CSS are you using? Tailwind v4.0.0-beta.8 What build tool (or framework if it abstracts the build tool) are you using? Vite v5.4.11, in an electron-vite app What version of Node.js are you using? v22.11.0 What browser are you using? Chrome (electronjs version 31.7.6 app) What operating system are you using? MacOS Describe your issue Hi, It seems components cannot have utilities such as md:, lg: or dark: applied to it. For instance, I defined a button.css file:
On a different nuxtjs project with tailwind v3 everything is working as expected. Thanks for you help |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@utility btn-lg {
@apply text-lg px-5 py-2;
}
@utility btn {
@apply inline-flex items-center justify-center
gap-1.5 px-3 py-1 font-semibold text-base text-white
rounded-xl border-1 border-white/40 select-none
focus:outline-4 focus:outline-blue-800/80 focus:outline-offset-2;
} |
Beta Was this translation helpful? Give feedback.
-
Thank you @philipp-spiess for you help :) But then how can i solve the following problem: https://play.tailwindcss.com/YguqPOJb2Q?size=848x720 The only solution i see is to use |
Beta Was this translation helpful? Give feedback.
Yeah so this is actually consistent with how v3 works, where you'd also need to do
!rounded-full
:https://play.tailwindcss.com/hXfUUkJ5dv?size=848x720&file=css
But here's a solution where you nest a layer inside of your custom utilities:
https://play.tailwindcss.com/h5WPle1YNh?size=848x720&file=css