-
DescriptionI define my vertical spacer recipes as atomic recipes :
The variable values come from semantic tokens as follows :
The documentation for Atomic Recipes states :
From this, I figure that the classes to be created at runtime, regardless of whether they are used or not, so that I may potentially use them dynamically when needed. I create my VerticalSpacer component as follows :
And then use that component in a generic component as follows :
Where topSpacingSize and bottomSpacingSize are sizes defined in the atomic recipe. h_var(--spacing-gap-xl) classes are applied to the class list but the actual css is not generated. Following the documentation
I've also tried to create staticCss by converting verticalSpacer to a config recipe and adding the The only way to get this dynamic functionality working is by using inline styles and interpolating the topSpacingSize and bottomSpacingSize into a height css rule (see below), which I would like to avoid if I can.
I understand that PandaCSS is not ideal for dynamic styling, but the documentation hints that it is possible. What am I missing to get this to work ? Any help is appreciated ! Link to ReproductionCheck description above. Will provide repro link if needed Steps to reproduceCheck description JS FrameworkNextJS (TS) Panda CSS Version0.21 BrowserNo response Operating System
Additional InformationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
the way you're referencing your spacing tokens is not "right" from Panda PoV, as the static extractor expects to see the token path instead of the raw CSS variable (that could be defined from anywhere, not specific to Panda) const verticalSpacer = cva({
base: {
w: 'full',
},
variants: {
size: {
sm: {
- h: 'var(--spacing-gap-sm)',
+ h: '{spacing.gap.sm}',
},
md: {
- h: 'var(--spacing-gap-md)',
+ h: '{spacing.gap.md}',
},
lg: {
- h: 'var(--spacing-gap-lg)',
+ h: '{spacing.gap.lg}',
},
xl: {
- h: 'var(--spacing-gap-xl)',
+ h: '{spacing.gap.xl}',
},
},
},
}) |
Beta Was this translation helpful? Give feedback.
the way you're referencing your spacing tokens is not "right" from Panda PoV, as the static extractor expects to see the token path instead of the raw CSS variable (that could be defined from anywhere, not specific to Panda)
https://play.panda-css.com/wbu7t3Ypda