-
DescriptionI've written a button component with 3 import { defineRecipe } from '@pandacss/dev';
export const buttonRecipe = defineRecipe({
className: 'button',
description: 'The styles for the Button component',
base: {
color: 'neutral.700',
p: '4px',
},
variants: {
variant: {
contained: {
bg: 'blue.500',
},
outlined: {
borderWidth: '4px',
},
text: {},
},
color: {
blue: {},
indigo: {},
purple: {},
},
},
compoundVariants: [
{
variant: 'contained',
color: 'blue',
css: {
bg: 'blue.500',
},
},
{
variant: 'outlined',
color: 'indigo',
css: {
border: 'indigo.500',
},
},
...
],
} I only use ...
@layer recipes {
.button--variant_outlined {
border-width: 4px;
}
@layer _base {
.button {
color: var(--colors-neutral-700);
padding: 4px;
}
}
}
@layer utilities {
.bg_blue\.500 {
background: var(--colors-blue-500);
}
.bg_indigo\.500 {
background: var(--colors-indigo-500);
}
.bg_purple\.500 {
background: var(--colors-purple-500);
}
.border_blue\.500 {
border-color: var(--colors-blue-500);
}
.border_indigo\.500 {
border-color: var(--colors-indigo-500);
}
.border_purple\.500 {
border-color: var(--colors-purple-500);
}
} As it can be seen, the Here is the question, why PandaCSS can not remove unused and extra Link to Reproductionhttps://stackblitz.com/edit/vitejs-vite-ygnv7y?file=src%2Fcomponents%2Fbutton.style.ts Steps to reproduce
JS FrameworkReact (TS) Panda CSS Version^0.17.3 BrowserNo response Operating System
Additional InformationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
compoundVariants generates atomic CSS in the if we JIT'd this as well, users would often expect those styles to be generated in simple cases that involves dynamic stuff const Button = ({ color, children }) => {
const [variant, setVariant] = useState("contained")
// ...
return <div className={button({ color, variant })}>{children}</div>
} which compoundVariants CSS should we generate in that case ? do we not generate anything unless using config.staticCss ? that doesn't look like a good DX btw for your use-case, it looks like you're looking for |
Beta Was this translation helpful? Give feedback.
compoundVariants generates atomic CSS in the
@layer utilities
due to static limitations, it's way easier to reason about if we just generate that CSS no matter the usage in your code (just like cva/sva)
if we JIT'd this as well, users would often expect those styles to be generated in simple cases that involves dynamic stuff
things like
which compoundVariants CSS should we generate in that case ? do we not generate anything unless using config.staticCss ? that doesn't look like a good DX
btw for your use-cas…