Better class merging utility function. #1131
Replies: 5 comments 8 replies
-
+1. putting it more simply for the following expression:
expecting:
actual:
|
Beta Was this translation helpful? Give feedback.
-
@rolanday This is exaclty what |
Beta Was this translation helpful? Give feedback.
-
+1 for this. I was just trying to fix a simple rendering issue on the Panda docs site, and I'm unable to proceed because I can't override some default padding defined at the component level. Given these two outputs: <div class="p_3 p_5">...</div>
<div class="p_5 p_3">...</div> The winner here will either be |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the improvement in #1195. Is there any way for |
Beta Was this translation helpful? Give feedback.
-
Description
Coming from tailwind, they have a utility package called tailwind-merge that allows to merge mutiple classnames into one and avoid conflicts.
From what I understood there is the
cx
utility function that acts the same in panda but not quite the way I expect it to work.Problem Statement/Justification
I have a simple
Card
component with acva
that has some pre-defined padding as a base.Then I merge the class passed as props with
cx
.For simplicity's sake, let's say the class given as props is
css({p:0})
. Since theclassList
given as props is the second arg ofcx
I expect it to override the base padding of thecard
cva
. However, I can see the padding is still there.Isn't that how
cx
is supposed to work ?Proposed Solution or API
The classes passed to
cx
(or maybe a potential new utility functionpandaMerge
) should merge in a way that the classes passed as second, third,... arguments should override the previous ones whenever they have conflicting classes.Alternatives
I can add an exclamation mark to make the passed class as important but that's not ideal.
I can add a
noPadding
variant to thecva
which setspadding: 0
but that's not ideal.Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions