-
Hi everyone, I'm experiencing an issue with Tailwind CSS v4 where variants (such as Issue Description
Expected BehaviorThe Actual BehaviorThe hover state does not get applied, and inspecting the generated CSS does not show the Steps Tried:
Questions:Is this an expected behavior change in Tailwind v4? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, see https://tailwindcss.com/docs/upgrade-guide#adding-custom-utilities.
Variants don't get applied at all anymore. As per above, Tailwind v4 no longer does anything "special" for CSS inside So, for equivalent in v4, you'd do: @utility btn-success {
@layer components {
display: flex;
align-items: center;
color: rgb(var(--c-white) / 1);
border: 1px solid transparent;
background-color: red;
transition: opacity 250ms ease-in-out;
}
} |
Beta Was this translation helpful? Give feedback.
-
@iamaliybi you can use the following entry: @layer components {
.btn-success {
display: flex;
align-items: center;
color: rgb(var(--c-white) / 1);
border: 1px solid transparent;
background-color: red;
transition: opacity 250ms ease-in-out;
&:hover {
@media (hover: hover) {
background-color: var(--color-violet-700);
}
}
}
} Here is the doc. |
Beta Was this translation helpful? Give feedback.
Yes, see https://tailwindcss.com/docs/upgrade-guide#adding-custom-utilities.
Variants don't get applied at all anymore. As per above, Tailwind v4 no longer does anything "special" for CSS inside
@layer
s.So, for equivalent in v4, you'd do: