nextui-org / tailwind-variants

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

Extending variants doesn't work when passing classes as an array #206

Open ApplePieGiraffe opened 1 month ago

ApplePieGiraffe commented 1 month ago

Describe the bug I'm using an array to pass class names into tailwind-variants

const styles = tv({
  base: [],
  variants: {
    type: {
      primary: ["bg-red-500"],
    },
  },
});

If I extend those styles and use an array to pass class names into the extended styles

const extendedStyles = tv({
  extend: styles,
  variants: {
    type: {
      primary: ["bg-green-500"],
    },
  },
});

Neither the original or extended styles get applied to the element. Instead the dev tools show

<button class="[object Object]">Count: 0</button>

To Reproduce See this Codesandbox

Expected behavior The extended styles should override the original styles and be applied to the element

ian-os commented 1 month ago

extend takes string not a tv() object

tianenpang commented 1 month ago

Hi @ApplePieGiraffe @ian-os for now, the temporary fix is to change the array to a string, and will look into this issue 🤔

I-am-tk commented 3 weeks ago

@tianenpang Changing main value from "main": "dist/index.cjs" to "main": "dist/index.js" in package.json seems to resolve this issue. :thinking: .