nesting @variant in @utility not working
#19247
-
|
What version of Tailwind CSS are you using? 4.1.16 What build tool (or framework if it abstracts the build tool) are you using? n/a What version of Node.js are you using? 22.21. What browser are you using? firefox What operating system are you using? linux Reproduction URL https://play.tailwindcss.com/4IeG0AH5t1 Describe your issue Nesting |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
It works as expected. The utility produces the following CSS: .not-working {
@media (width >= 40rem) {
color: blue;
}
color: red;
}The .not-working {
color: blue;
color: red;
}When there are duplicate properties in a single rule, the last declaration wins. Thus, Another way to look at it is when the CSS is flattened into non-nested syntax: @media (min-width: 40rem) {
.not-working {
color: #00f;
}
}
.not-working {
color: red;
}Again, we can see that the |
Beta Was this translation helpful? Give feedback.
It works as expected. The utility produces the following CSS:
The
@mediaat-rule does not contribute to specificity, so when the@mediacondition passes, it is like:When there are duplicate properties in a single rule, the last declaration wins. Thus,
not-workingwill always bered, which is standard CSS behavior.Another way to look at it is when the CSS is flattened into non-nested syntax:
Again, we can see that the
color: redrule comes after the@mediaquery. Si…