When overriding flex-1
, two utilities are generated in the output
#18944
Replies: 6 comments
-
Hey! This is expected behavior right now because we don't have a concept of overriding utilities at this time. If you use Going to keep this open a little longer because while it's not a bug, I also don't want to forget about this. We probably want to introduce some keyword to mark the utility that it overrides instead of extends. |
Beta Was this translation helpful? Give feedback.
-
Would also love a way to mark a @Utility as being an override rather than extending. It's kind of how I thought it would work by default to be honest, but glad that this is at least on someone's radar! |
Beta Was this translation helpful? Give feedback.
-
Also expected @Utility to override exisiting classes if they already exist. To be honest this is in my oppinion the whole point of using @Utility in the first place since you're registering them to the tailwindcss process. With tailwindcss v3 you could easily override exisiting classes AFIK using presets. I've come across multiple uses for overriding that you simply cannot do in tailwindcss v4 as of right now since the css variables only cover a little of the customization possibilities. For example changing --spacing would affect the padding but no option exists for heights and widths. Ofcourse you can add many custom css variables but I'd prefer more flexibility in customizing tailwind using @Utility and perhaps more css variables for common things such as heights, widths, margins, border-widths etc. I hope this is planned, as I think it could be very helpful to people using tailwind. |
Beta Was this translation helpful? Give feedback.
-
The reason Even with presets as you mentioned, you would extend plugins, never override them: https://play.tailwindcss.com/1vGd9vx2iQ?file=config It's true that you could override theme values via presets that way in v3: But that behavior also exists in v4: |
Beta Was this translation helpful? Give feedback.
-
Oh I see! My bad @RobinMalfait I misunderstood, could it be possible to override existing utility classes in the future by specifying a sort of override flag to the |
Beta Was this translation helpful? Give feedback.
-
Hey folks! Going to move this to a discussion since it's not a bug but currently expected behavior and we tread ideas/feature requests in the discussion forum instead 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What version of Tailwind CSS are you using?
For example: v4.1.8
What build tool (or framework if it abstracts the build tool) are you using?
Tailwind Play
Reproduction URL
https://play.tailwindcss.com/JbMqs7VnW1?file=css
Describe your issue
The expected result would be just one utility, the new one:
But the old one is also implemented:
If I override the entire flex-* utility, at least the specificity will be correct:
https://play.tailwindcss.com/yPtNMkQL2r?file=css
Beta Was this translation helpful? Give feedback.
All reactions