Feature request: Add a “responsive reset” behavior to allow overriding all breakpoint variants of a class group #628
Replies: 2 comments 2 replies
-
|
Hey @maximepvrt, thanks for the long wait! 👋 I see the problem too, handling breakpoints with tailwind-merge isn't the best experience right now. I thought about solving this in the past but couldn't find a solution that worked UX-wise. One of the unsolved problems to me is what to do in cases where conflicting base classes are used with other modifiers or where brekapoints are used together with other modifiers. I.e. cases like these: // ↓ Should any of these override breakpoints?
twMerge("p-4 md:p-6", "hover:p-2 p-2!")
// ↓ Should any of these override breakpoints?
twMerge("p-4 hover:lg:p-6", "p-2 dark:md:p-2")I can imagine that what to do in these cases is dependent on the specific use case context and that there isn't a universal answer I could bake into tailwind-merge. But I would be happy to implement something to handle breakpoints better if there is one. |
Beta Was this translation helpful? Give feedback.
-
|
@dcastil Thanks for your detailed explanation, makes a lot of sense! One simple idea could be to introduce an explicit “reset” class, e.g. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m using tailwind-merge inside a design system that autogenerates responsive classes (Nuxt UI in my case, but the problem applies to any UI library doing this).
When I try to override a class group (e.g. padding), I can override the base class, but not all responsive variants.
❌ Current behavior
Result:
The base padding gets overridden (
p-4 → p-2), but all responsive variants remain untouched.🧩 Why this is a real issue in the ecosystem
When a design system generates responsive classes that I don’t directly control:
xl:), my overrides suddenly breakExample:
After a design system update adds a new breakpoint (e.g.
xl:):I now need to manually add
xl:p-2, and the problem repeats every time new breakpoints are introduced.🧨 Practical consequences
This becomes:
🙏 Feature request
Add a way to reset all variants of a class group when one override is applied.
Beta Was this translation helpful? Give feedback.
All reactions