Override CVA/SVA styles with className #1673
-
I am wondering if there is any way to easily override cva/sva variant classes with classes provided to the component later
In this example the button will have a background of red and a width of 200px. The bg of red takes precendence over the background of orange. This doesn't work like it typically would, as Most styling libraries produce classNames, and are unaware of the css prop so want a solution that can play nice with other libraries (which involves the component taking a className to override styles) I have figured I can do I believe this has to do with the order that the css is generated.. maybe the cva/sva stuff is generated after any css() styles? maybe if there was a way to scope the generated css to give it more specificity ? e.g Am now thinking maybe it would work with external libs passing className as long as those styles/css were on the page after anything generated by Panda.. regardless it would be good to find a way that we can do this in systems just using Panda
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @outofthisworld, You can achieve style merging by using the
const mergedClassName = css(Test.raw(...), { bg: "orange", width:"200px" }) |
Beta Was this translation helpful? Give feedback.
-
Thanks @segunadebayo. Just lastly what in the following scenario?
Is that always going to work? It should for user defined styles right? but for instance this wouldn't...
|
Beta Was this translation helpful? Give feedback.
Hi @outofthisworld,
You can achieve style merging by using the
.raw(...)
method on the cva, and merging the styles with the css function.