Class groups validator not behaving as expected #150
Unanswered
AleksiKytola
asked this question in
Help
Replies: 1 comment 2 replies
-
Hey @AleksiKytola! 👋 Your code should be correct. I just tested this code below in which import { extendTailwindMerge } from 'tailwind-merge'
export const twMerge = extendTailwindMerge({
classGroups: {
shadowClassGroup: [{ shadow: [() => true] }],
},
});
console.log(twMerge('shadow-lol shadow-2 shadow-fjjalsdua8sdadjkasdh-dasdasd-aw-d shadow-[4]')) But be aware that you shouldn't use a catch-all validator for I'd suggest to either keep using string literals or define a more narrow validator for shadows, like this one: const isNotShadowColor = (value: string) => !/^[a-z]+-\d+(\/\d+)?$/i.test(value) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to make a class group for any "shadow-" classes. In my case I have some shadows such as 'card' or 'none' defined, and everything works just fine if I use them as literals in the class group
However if I try to use the option of adding a validator function, it doesnt seem to do anything
Doesn't remove either shadow-card or shadow-none from a classlist that has both. If I understood the documentation correctly this classgroup should match any "shadow-" classes now?
Not sure whether its a bug or I'm misusing it? I even tried adding a console.log into the
anyClassSuffix
function and I'm not seeing any logging happening in my console so I'm not sure if the validator is even being calledBeta Was this translation helpful? Give feedback.
All reactions