Replies: 1 comment 1 reply
|
the two classes stick around because panda only collapses conflicting atomic styles inside a single style pipeline. Stacking styled() over an already-styled component just concatenates two separate className strings, so c_green and c_red both land on the node. Injection order is what makes the color still look right. so it's expected rather than a bug. To keep one deduped class, merge at the style-object level instead of wrapping. On 1.11.4 I get class="c_red" from either the css prop: or merging raw objects: css(base.raw(), { color: 'red' }). Same thing #3357 landed on, and it's the "Merging within JSX component" section of the Merging Styles docs. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Consider the following example:
In this example,
CustomRootforwards all of its props to an already styled component (StyledRoot).When
CustomRootis wrapped again withstyled, the resulting element receives both the original (green) and the new (red) color class names. While the rendered color appears correct because of the class name generation/injection order, both classes remain on the element.I was expecting the outer
styled()call to effectively override or merge the styles so that only the finalcolordeclaration is emitted, avoiding duplicate/conflicting utility classes.What is the recommended pattern for composing styled components like this while keeping the generated class names deduplicated?
If this isn't currently supported, would you consider adding support for this kind of style merging/composition? Is it already on the project roadmap or planned for a future milestone?
Edit: Playground Link - https://play.panda-css.com/JmHZuKWRTK
All reactions