-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
What version of Tailwind CSS are you using?
v3.3.5
What build tool (or framework if it abstracts the build tool) are you using?
tried angular 13 and angular 16
What version of Node.js are you using?
v18.10.0
What browser are you using?
Chrome, Firefox
What operating system are you using?
Windows, macOS
Reproduction URL
https://github.com/MarKayS/tailwind-angular-dark-bug
Describe your issue
When using @apply with dark mode set to class and angular viewEncapsulation is not disabled, the dark: rules are also scoped.
Using this simple css:
:host{
@apply text-amber-900 dark:text-amber-500;
}This is how the dark style is generated with tailwind 3.3+:
:is(.dark )[_nghost-mxl-c11] {
--tw-text-opacity: 1;
color: rgb(245 158 11 / var(--tw-text-opacity))
}Same style with tailwind 3.2.0:
.dark [_nghost-kar-c11] {
--tw-text-opacity: 1;
color: rgb(245 158 11 / var(--tw-text-opacity))
}This means that I would have to add .dark class to every component, turn off viewEncapsulation or use hostBinding insted of apply.
In previous versions there were spaces after the .dark . The same is true in 3.3, but the spaces are inside the :is function :is(.dark ).
I think the error comes from
tailwindcss/src/corePlugins.js
Line 228 in b411d04
| addVariant('dark', `:is(${className} &)`) |
I believe changing it to the following line should resolve the issue and hopefully not break anything:
addVariant('dark', `:is({className}) &`)
Should I submit a PR?