Custom Screen Breakpoints Order Causes Unexpected Override Due to Alphabetical Sorting #16979
Unanswered
liuhuakawaii
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
When using custom screen breakpoint names with non-alphabetical size progression, the generated CSS media queries appear to be ordered alphabetically rather than by actual breakpoint values. This leads to unexpected overrides between breakpoints.
Steps to Reproduce:
Define custom screens in tailwind.config.js:
Use conflicting utilities across breakpoints:
Observe compiled CSS order:
Expected Behavior:
Breakpoints should cascade based on their actual numeric values regardless of name. At 1920px:
lg:h-[36px] should override xs:h-[28px]
lg:py-2 works correctly because there's no conflicting utility
Actual Behavior:
xs:h-[28px] overrides lg:h-[36px] at 1920px because its media query appears later in CSS
Utilities work correctly only when breakpoint names happen to be alphabetically ordered (e.g., sm < md < lg)
Investigation Findings:
Renaming lg to wlg changes the CSS order, confirming alphabetical sorting
Documentation mentions alphabetical ordering (Reference):
"Breakpoints are sorted alphabetically [...] this means [...] breakpoints with longer names will come after shorter ones"
Feature Request:
Provide a mechanism to explicitly define media query generation order, either through:
Array-based screen configuration
Priority number system
Automatic value-based sorting
Beta Was this translation helpful? Give feedback.
All reactions