-
Notifications
You must be signed in to change notification settings - Fork 70
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
Custom Tailwind theme variables are not applied if a different modifier is being applied to the same keyword (text-white + text-custom) #201
Comments
I have this issue too, custom properties are being ignored when tv transform i create a mini repo with the reproducible issue |
Same problem here. It happens across variants as well
|
The issue stems from TwMerge. You need to customize the TwMerge configuration (shadcn had the same issue with his cn() function). I am trying to do something similar for tv() but without success so far const customTv = createTV({
twMergeConfig: customTwMergeConfig, // build with extendTailwindMerge()
});
export function ctv(classes) {
return customTv(classes);
} |
I had the same issue, import { createTV, VariantProps } from 'tailwind-variants';
export const twMergeConfig = {
extend: {
classGroups: {
'font-size': [{ text: ['xxs'] }],
},
},
};
export type { VariantProps };
export const tv = createTV({
twMergeConfig,
}); The only issue is that i find the documentation of |
I found the issue for my particular case: I had to make sure tailwind-variants was deduped with nextui's, so that the same configuration is applied to both: Before:
After:
|
Describe the bug
If I extend the Tailwind config with a custom property name for
fontSize
and try to apply it throughtv
the class name is present in thetv
output only if there are no other class names referencing the same keyword. For example, if I have bothtext-white
andtext-component-sm
the output only containstext-white
instead oftext-white text-component-sm
.Note, that with the last version of CVA the output is as I was expecting it.
To Reproduce
I created an example stackblitz to demo the issue: https://stackblitz.com/edit/stackblitz-starters-k5mnqu?file=app%2Fpage.tsx
Steps to reproduce the behavior:
tailwind.config.ts
with some custom properties that may be applied to thetext
keyword (ex. extendfontSize
)tv
function that only selectstext-customVar
as a class name for thetext
keywordtv
returns the class in its output stringtv
function that selectstext-customVar
and a second one (ex. text-white) as a class name for thetext
keywordtv
only returns in its output string the class with the default property nameExpected behavior
If I provide both
text-white
andtext-component-sm
totv
the output should containtext-white text-component-sm
.Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
untested
Additional context
this is an issue that applies to the node environment as well (for example through Next.js)
The text was updated successfully, but these errors were encountered: