-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark mode classes rely on order when using @apply #2826
Comments
Hey! TL;DR:This will only happen when you use multiple A bit more detailsWhen you use multiple @media (prefers-color-scheme: dark) {
.first {
--tw-text-opacity: 1;
color: rgba(239, 68, 68, var(--tw-text-opacity));
}
}
.first {
--tw-text-opacity: 1;
color: rgba(59, 130, 246, var(--tw-text-opacity));
}
.last {
--tw-text-opacity: 1;
color: rgba(59, 130, 246, var(--tw-text-opacity));
}
@media (prefers-color-scheme: dark) {
.last {
--tw-text-opacity: 1;
color: rgba(239, 68, 68, var(--tw-text-opacity));
}
} You can see that for the This is also why that scenario only happens when using the If you move your declaration inside a single .first {
@apply dark:text-red-500 text-blue-500;
}
.last {
@apply text-blue-500 dark:text-red-500;
} The styles are now generated in the correct order: .first {
--tw-text-opacity: 1;
color: rgba(59, 130, 246, var(--tw-text-opacity));
}
@media (prefers-color-scheme: dark) {
.first {
--tw-text-opacity: 1;
color: rgba(239, 68, 68, var(--tw-text-opacity));
}
}
.last {
--tw-text-opacity: 1;
color: rgba(59, 130, 246, var(--tw-text-opacity));
}
@media (prefers-color-scheme: dark) {
.last {
--tw-text-opacity: 1;
color: rgba(239, 68, 68, var(--tw-text-opacity));
}
} In that scenario, your problem goes away. Hope it helps! 👍 |
Ahh! Thank you for the incredibly detailed response, that makes perfect sense. I've definitely been abusing the Thanks! |
Describe the problem:
When using dark-mode, the order of
@apply
classes is affecting whether or not they work. The expectation is that when dark-mode is active, the@apply dark:
style should apply.Link to a minimal reproduction:
https://play.tailwindcss.com/ZVedYuKwvV
The text was updated successfully, but these errors were encountered: