-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Media queries nested inside selector is correctly processed in build mode, but not dev mode #16438
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
Comments
Hey @hugentobler. Do you mind attaching a small reproduction for this that we can run locally? I'm curious which post-processing step adds the space between the Maybe a work-around would be to use |
Hi @philipp-spiess sorry the space between |
What version of Safari are you using? |
Safari v18.3 |
Just to continue this issue: In the skeleton framework, a nested media query is also used and we're encountering a similar issue. Being that the contents inside the query are not recognized by Safari: :root {
color-scheme: light;
@variant dark {
color-scheme: dark;
}
} So on @layer base {
@media (prefers-color-scheme:dark) {
body {
color: var(--base-font-color-dark);
}
}
} |
Seems like the following is always failing for me using regular @utility my-button {
color: blue;
@media (width >= theme(--breakpoint-md)) {
color: red
}
} Currently have to do: .my-button {
color: blue;
}
@media (width >= theme(--breakpoint-md)) {
.my-button {
color: red;
}
} |
@Cretezy just FYI we encountered similar issues with media queries for breakpoints. Variants are supported for these specifically. @utility my-button {
color: blue;
@variant md {
color: red
}
} |
I wanted to help showcase @nwrenger 's issue here. Here's a minimal reproduction: https://play.tailwindcss.com/4zRUzHyTow?file=css Kapture.2025-03-21.at.13.04.07.mp4The catch being is this does not show the error, it's fully functional in Safari. But that's the weird part of this issue - it seems to be restricted to ONLY dev servers for SvelteKit and Astro apps (so far).
To make matters more more interesting, the issue seems to have been introduced in macOS 15 Sequoia. The version of Safari is tied to the OS, so here's a quick comparison. Here's an Astro-based app using light-dark + color scheme on Safari 17.5 safari-17.5.mp4And then again on Safari 18.3.1 safari-18.3.1.mp4My theory here is something has change in the latest version of macOS/Safari that's affecting the Vite dev server for SvelteKit and Astro based apps. I'm not 100% sure this is an issue on Tailwind's end, but we might need some coordination between Tailwind/Vite to figure this one out. |
What version of Tailwind CSS are you using?
v4.0.6
What browser are you using?
This is a Safari issue.
I am working with svelte files. I had implemented media queries nested inside of selectors which were working just fine in Chrome. However when I was testing in Safari, I realised that nesting media queries inside of selectors is technically invalid syntax, even though Chrome is able to render it.
So looking into it, I realised that postcss processes the styles into valid markup in build mode, but not in dev mode. So Safari renders it correctly in build mode but not dev mode.
I'm wondering what is the suggested way to use media queries in svelte files then. (I know this is not the preferred utilities-based tailwind syntax, but I have this use-case where I don't want to inline these styles). And also wondering if there is a postcss issue on dev or the aforementioned behaviour is expected.
The text was updated successfully, but these errors were encountered: