Merging className with Priority in cx #1468
-
Hello everyone, I'm currently working with the cx function from 🐼 in a React component. My goal is to merge styles received from Props (crafted with PandaCSS's css) with a predefined baseStyle. However, I've hit a snag. Here's what I'm doing: <div className={cx(baseStyle, styleFromProps)}>some text</div> When there's an overlap between styleFromProps and baseStyle, I want to ensure that the styles from styleFromProps take precedence. Does anyone have a nifty solution for this? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@Kakeru-Miyazaki |
Beta Was this translation helpful? Give feedback.
-
Oh, my apologies. This is precisely what I've been searching for. I truly appreciate your help. Thank you so much. |
Beta Was this translation helpful? Give feedback.
@Kakeru-Miyazaki
cx
is just a string concatenator, becausecss
resolve to string classNames.To merge styles see https://panda-css.com/docs/concepts/writing-styles#merging-styles