Styled props are ~30% slower at render than cva or css #2604
Replies: 4 comments 13 replies
-
How do you measure this benchmark? Could share some reproduction? |
Beta Was this translation helpful? Give feedback.
-
@kris-ellery I personally use the CSS prop to use less runtime as possible |
Beta Was this translation helpful? Give feedback.
-
I think it's quite fast already, given the constraints (if it can be improved we'd be happy to merge that in)
I didnt understand this part, can you explain ? |
Beta Was this translation helpful? Give feedback.
-
To improve the performance here, I would recommend taking a look at the split props implementation in the styled-system folder, and try to write a faster implementation. Once you figure it out, you can contribute back my opening a PR. |
Beta Was this translation helpful? Give feedback.
-
Hello friends!
As we refactor our design system components to use TS and Panda, we are also running performance benchmarks. Recently, I tested the 100 Button components and noticed poor render results. After some investigation, I found the culprit: the styled props.
Panda offers two ways to create styled props: either via
styled.button
or via thesplitCssProps
hook that separates styled props from the rest.Both examples allow consumers to pass styled props that generate atomic utility class names.
Both approaches use the same
splitProps
method. This operation is costly and, for our performance test of 100 Buttons, it has increased the mount time by 30% and re-render by 40% in a Next 14 and React 18 environment.Clearly, we're not happy about this and wonder if leveraging the
css
prop and skippingsplitCssProps
altogether is the way to go.Here is an example of using the
css
prop rather than individual styled props from the previous example:This issue does not seem specific to Panda; it's something every static CSS library deals with — the mapping of props and their values to the correct class names.
So the question is, can we make styled props faster or do we have to use
css
prop to maximize performance? Note, we had zero success with unplugging and removing Panda's runtime in our setup.Beta Was this translation helpful? Give feedback.
All reactions