Skip to content

How to refer variants in globalStyle and intersected variants #549

Answered by Spaubleit
Spaubleit asked this question in Q&A
Discussion options

You must be logged in to vote

After some investigation I found a solution. You can use styleVariants to refer each variant class. In my example it would be like this:

export const disabled = style({})

export const buttonStyleVariants = styleVariants({
    gradient: {},
    outline: {},
    clear: {
        color: themeVars.colors.text.default,
        selectors: {
            [`&:hover:not(${disabled})`]: {
                color: themeVars.colors.text.light,
            },
        }
    },
})

export const button = recipe({
    variants: {
        style: buttonStyleVariants,
    },
})

globalStyle(`${buttonStyleVariants.clear} svg`, {
    fill: themeVars.colors.icon,
})

globalStyle(`${buttonStyleVariants.clear}:hove…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Spaubleit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants