nextui-org / tailwind-variants

🦄 Tailwindcss first-class variant API
https://tailwind-variants.org
MIT License
2.42k stars 70 forks source link

`defaultVariants` that are `true` can't be set by the consumer (boolean variants) #150

Closed tronikelis closed 9 months ago

tronikelis commented 10 months ago

Describe the bug If you have variants like this {foo: {true: "bar"}} and have defaultVariants: { foo: true }, then if the consumer sets foo as false, it does not remove the styles

To Reproduce Steps to reproduce the behavior:

const card = tv({
  base: "",
  variants: {
    foo: {
      true: "bar",
    },
  },

  defaultVariants: {
    foo: true,
  },
});

console.log([card({ foo: false })]); // ["bar"]
console.log([card({ foo: undefined })]); // ["bar"]

Expected behavior If foo is false, then it should have the relevant styles removed

Desktop (please complete the following information):

Additional notes This might be related to: https://github.com/nextui-org/tailwind-variants/issues/141

mskelton commented 10 months ago

@Tronikelis I updated my open PR to also fix this