Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Lack of docs for compoundVariants option #53

Closed
dhutaryan opened this issue Mar 7, 2024 · 1 comment
Closed

[Documentation] Lack of docs for compoundVariants option #53

dhutaryan opened this issue Mar 7, 2024 · 1 comment

Comments

@dhutaryan
Copy link

Hello, I'm trying yo use compoundVariants option because it's very useful in my case. I guess it should work the similar as in stitches but I didn't find any examples in documentation. Could you add some?

@Mokshit06
Copy link
Member

Hi! compoundVariants do indeed work very similar to how they do in stitches. The docs still need some work with more examples, but there's one on the home page itself https://macaron.js.org/

const Button = styled('button', {
  base: {
    borderRadius: 6,
  },
  variants: {
    color: {
      neutral: { background: 'whitesmoke' },
      accent: { background: 'slateblue' },
    },
    rounded: {
      true: { borderRadius: 999 },
    },
  },
  compoundVariants: [
    {
      variants: {
        color: 'neutral',
        rounded: true,
      },
      style: { background: 'ghostwhite' },
    },
  ],
  defaultVariants: {
    color: 'accent',
  },
});

So here when the variants color=neutral and rounded=true are applied at the same time, the background color would get set to ghostwhite :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants