Skip to content

How to add conflicting classes bypass? #256

Answered by dcastil
tanshunyuan asked this question in Help
Discussion options

You must be logged in to vote

Hey @tanshunyuan! 👋

There are several things in here:

Where to place call to extendTailwindMerge

Regarding your cn helper function, I'd strongly advice to put the extendTailwindMerge call outside of the cn function. In that call a lot of setup is happening and if you call the function on every cn call, you're doing that setup over and over again which might degrade the performance of your app unnecessarily. This code should fix this:

import { clsx, type ClassValue } from https://github.com/lukeed/clsx;
import { extendTailwindMerge } from https://github.com/dcastil/tailwind-merge;

const customTwMerge = extendTailwindMerge({});

const cn = (...inputs: ClassValue[]) => {
  const modfiedInput =

Replies: 1 comment 1 reply

Comment options

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

Answer selected by tanshunyuan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
context-v1 Related to tailwind-merge v1
2 participants