joe-bell / cva

Class Variance Authority
https://cva.style
Apache License 2.0
5.46k stars 107 forks source link

[Feature request] Styles conditional upon other styles #264

Closed nukeop closed 5 months ago

nukeop commented 5 months ago

Let's say I have a cva style defined like this:

const contextMenuItem = cva(
    'flex',
    {
        variants: {
            intent: {
                warning: 'text-red-500',
            },
            active: {
                true: 'bg-stone-100',
            },
        },
    },
);

So now I'd like to do something like this: if active is set to true, then intent with the value of warning should also apply bg-red-100 in addition to the style shown here. Is it possible, using the library in its current state?

nukeop commented 5 months ago

Nvm, I realized compound variants can do that. Thanks for thinking of everything.

elbasan commented 3 months ago

how did you manage to do this? i'm struggling to come up with a solution with dark mode components