Nested SCSS selectors breaking `@apply` directive
See original GitHub issueWhat version of Tailwind CSS are you using?
v3.2.1
What build tool (or framework if it abstracts the build tool) are you using?
Laravel Mix v6.0.49
What version of Node.js are you using?
v16.18.0
What browser are you using?
N/A
What operating system are you using?
macOS Ventura
Reproduction URL
https://github.com/shengslogar/tailwind-scss-nesting-bug-report/blob/main/output.css#L469-L493
Describe your issue
Complex nested SCSS selectors seem to be breaking the @apply
directive.
Input:
.foo {
&:not(.bar) {
@apply bg-red-100;
background: red;
&.baz > .bam {
@apply bg-orange-100;
background: orange;
}
}
}
Output:
.foo:not(.bar) {
--tw-bg-opacity: 1;
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
background: red;
}
.foo.baz.bam:not(.bar) > {
--tw-bg-opacity: 1;
background-color: rgb(255 237 213 / var(--tw-bg-opacity));
}
.foo:not(.bar).baz > .bam {
background: orange;
}
Expected Output:
.foo:not(.bar) {
--tw-bg-opacity: 1;
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
background: red;
}
.foo:not(.bar).baz > .bam {
--tw-bg-opacity: 1;
background-color: rgb(255 237 213 / var(--tw-bg-opacity));
background: orange;
}
Thanks in advance! 🙏
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
CSS Nesting Module - W3C
This module describes support for nesting a style rule within another style rule, allowing the inner rule's selector to reference the elements ...
Read more >CSS selectors - CSS: Cascading Style Sheets - MDN Web Docs
CSS selectors define the pattern to select elements to which a set of CSS rules are then applied.
Read more >Help pick a syntax for CSS nesting - Hacker News
Requiring directly-nested style rules to use nest-prefixed selectors works around this problem—an & can never be part of a declaration, so the parser...
Read more >Sass: @-Rules and Directives - CSS - Vanseo Design
The @at-root directive tells the compiler to move nested code to the root of the stylesheet. It allows you to nest rules inside...
Read more >Functions & Directives - Tailwind CSS
Use the @tailwind directive to insert Tailwind's base , components , utilities and variants styles into your CSS. /** * This injects Tailwind's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just tagged a real release for you too 👍
We’ll tag a proper release probably on Monday! In the mean time can just
npm install tailwindcss@insiders
to use the insiders build.