Skip to content

@utility Custom Functional Utilities Not Generating Classes in Output CSS if use tailwind-merge / clsx #18505

Answered by selllami
selllami asked this question in Help
Discussion options

You must be logged in to vote

Thank you for your help!

I found the exact issue: I’m using a custom cn() :

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

It turns out that twMerge can sometimes remove or not recognize custom utility classes generated with @utility, so the classes like text-stroke-width-[1px] were not being applied.
When I use plain className="text-stroke-width-[1px] " without cn() it works as expected.

So the problem was with my usage of cn() and not Tailwind itself.

Thanks again for pointing me in the right direction!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@selllami
Comment options

Answer selected by selllami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants