diff --git a/src/__tests__/tv.test.ts b/src/__tests__/tv.test.ts index 1a5319a..4f61f3f 100644 --- a/src/__tests__/tv.test.ts +++ b/src/__tests__/tv.test.ts @@ -1156,6 +1156,7 @@ describe("Tailwind Variants (TV) - Slots", () => { base: "color--secondary-base", title: "color--secondary-title", }, + tertiary: {}, }, }, compoundVariants: [ @@ -1165,6 +1166,16 @@ describe("Tailwind Variants (TV) - Slots", () => { title: "truncate", }, }, + { + color: "tertiary", + class: ["color--tertiary-base"], + }, + { + color: "tertiary", + class: { + title: "color--tertiary-title", + }, + }, ], defaultVariants: { color: "primary", @@ -1181,6 +1192,8 @@ describe("Tailwind Variants (TV) - Slots", () => { "color--secondary-title", "truncate", ]); + expect(base({color: "tertiary"})).toHaveClass(["text-3xl", "color--tertiary-base"]); + expect(title({color: "tertiary"})).toHaveClass(["text-2xl", "color--tertiary-title"]); }); test("should work with native prototype", () => { diff --git a/src/core.js b/src/core.js index 22557fe..2646c00 100644 --- a/src/core.js +++ b/src/core.js @@ -310,7 +310,7 @@ export const getTailwindVariants = (cn) => { for (let i = 0; i < compoundClassNames.length; i++) { const className = compoundClassNames[i]; - if (typeof className === "string") { + if (typeof className === "string" || Array.isArray(className)) { result.base = cnFn(result.base, className)(config); } else if (typeof className === "object") { for (const slot in className) {