Repository navigation
|
How do we use that now? For example, my previous config just has: export const tv = createTV({
twMerge: true,
twMergeConfig: {
prefix: "tw",
},
});but this is now invalid with the latest version... edit: I realized I probably left out some important context in the original question, we have multiple projects pulling from multiple tailwind configs/themes, so we need to be able to merge prefixed and unprefixed classes. Currently I do so by doing function coercePrefixedClassName(className: string) {
return className.startsWith("tw:") ? className : `tw:${className}`;
}
// ...
export const tv = createTV({
twMerge: true,
twMergeConfig: {
prefix: "tw",
experimentalParseClassName({ className, parseClassName }) {
return parseClassName(coercePrefixedClassName(className));
},
} |
Replies: 1 comment 3 replies
|
For a Tailwind v4 prefix you don't need it. In v4 the prefix is a leading variant ( export const tv = createTV({ twMerge: true }) // twMerge is already the defaultI compared 3.3.1's
One difference that shouldn't matter: with If you depend on some other tailwind-merge option the new resolver doesn't support, you can pin |
@Redmega thanks, that changes the answer. Merging unprefixed classes with prefixed ones is exactly the case I waved off at the end of my answer, so dropping
twMergeConfigwon't work for you.3.3.1 can't do this through config. It copies
prefixandexperimentalParseClassNameout oftwMergeConfig(tw-merge.ts), but the built-in merger only applies the class-group keys (merge-configs.ts), so both are dropped.twis then just another variant, sopx-2andtw:px-4get different conflict keys (config-utils.ts) and both survive.You can still upgrade. Turn off the built-in merge and run the output through your own tailwind-merge instance. 3.3.1 still lists
tailwind-merge >=3.0.0as an optional pe…