px breakpoints sorted before rem in generated CSS causing wrong cascade order #20033
Replies: 3 comments 2 replies
-
|
As per the documentation:
If you really want to use @import "tailwindcss";
@theme {
--breakpoint-sm: 640px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
…
} |
Beta Was this translation helpful? Give feedback.
-
|
The confusing part is that So if you only define: @theme {
--breakpoint-md: 400px;
--breakpoint-lg: 992px;
}you can still run into ordering problems against the remaining default The two safe options are: @theme {
--breakpoint-md: 25rem;
--breakpoint-lg: 62rem;
}or override all breakpoints using the same unit, so there is no px/rem mix in the generated responsive utilities. So yes, |
Beta Was this translation helpful? Give feedback.
-
|
This is actually by design in v4 — Tailwind sorts breakpoints alphabetically when they're raw CSS values, and The fix is to stick with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
When setting a breakpoint using
pxin@theme, it does not workcorrectly. But the same value in
remworks fine.Versions
Code to Reproduce
@theme {
--breakpoint-lg: 992px; (does not work)
--breakpoint-lg: 62rem; (works perfectly)
}
Expected
992px and 62rem are the same width (992 / 16 = 62rem),
so both should behave identically.
Actual
px gets sorted before rem defaults in generated CSS,
so md: styles override lg: styles incorrectly
between 992px and 1024px.
Workaround
Use rem instead of px.
Beta Was this translation helpful? Give feedback.
All reactions