Replies: 1 comment 1 reply
-
|
@jeiea your In your example, you don't need to use Your recipe: const button = defineRecipe({
className: 'button',
variants: {
color: { primary: {}, secondary: {} },
},
compoundVariants: [
{
color: 'primary',
css: { bg: 'green' },
},
{
color: 'secondary', css: { bg: 'red' }
},
],
defaultVariants: { type: 'fill', color: 'primary' },
})Updated recipe: const button = defineRecipe({
className: 'button',
variants: {
color: {
primary: {
bg: 'green'
},
secondary: {
bg: 'red'
}
},
},
defaultVariants: { color: 'primary' },
})With the mentioned changes you can do this: export const App = () => {
return (
<div className={center({ h: 'full' })}>
<div
className={css({
display: 'flex',
flexDirection: 'column',
fontWeight: 'semibold',
color: 'yellow.300',
textAlign: 'center',
textStyle: '4xl',
})}
>
<span>🐼</span>
<span>Hello from Panda</span>
<button className={cx(
button({ color: 'primary' }),
css({ bg: 'red' })
)}>text</button>
<button className={cx(
button({ color: 'secondary' }),
)}>text</button>
</div>
</div>
);
};Check the playground: https://play.panda-css.com/nC_oN61b_s Additional resources:
Hope this helps you ✌️ |
Beta Was this translation helpful? Give feedback.
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.
-
Steps to reproduce
https://play.panda-css.com/fdAjbJzH9T
Expected behavior
Both buttons should have red background.
Actual behavior
Can't override the first button's bg style.
Questions
What is the recommended way to override compound variant styles?
Beta Was this translation helpful? Give feedback.
All reactions