Skip to content

Whats the recommended way of approaching "references"? #245

Answered by airtonix
lstephensca asked this question in Q&A
Discussion options

You must be logged in to vote

if "primary" is used as the type and "rose" is used for the color, the class would be "bg-rose-500".

you want "compound variants".

export const baseButtonVariants = cva({
  base: "relative flex w-full transition-all duration-100 ease-in-out",
  variants: {
    type: {
      primary: "",
      accent: "",
    },
    primaryColor: {
      rose: "",
      orange: "",
    },
    accentColor: {
      rose: "",
      orange: "",
    },
  },
  compoundVariants: [
    {
      intent: "primary",
      primaryColor: "rose",
      className: "bg-rose-500"
    },
  ]
});

compoundVariants can be though of as situational overrides.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lstephensca
Comment options

Answer selected by lstephensca
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