Skip to content
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

Backgrounds not merging properly on Tailwind v4 + tailwind-merge v3 #520

Closed
AlanMorel opened this issue Jan 30, 2025 · 3 comments
Closed
Labels
context-v3 Related to tailwind-merge v3

Comments

@AlanMorel
Copy link

Describe the bug

Backgrounds not merging properly on Tailwind v4 + tailwind-merge v3

To Reproduce

const before = "bg-black/15 bg-linear-to-b";
const after = twMerge(before);

console.log("before", before);
console.log("after", after);

I get

before bg-black/15 bg-linear-to-b
after bg-linear-to-b

Expected behavior

before bg-black/15 bg-linear-to-b
after bg-black/15 bg-linear-to-b

These two Tailwind classes can be used together. It worked when I was on Tailwind v3 + tailwinnd-merge v2, and it works when I manually add the class back.

Environment

"tailwind-merge": "^3.0.1",
"tailwindcss": "^4.0.1",

@github-actions github-actions bot added the context-v3 Related to tailwind-merge v3 label Jan 30, 2025
@dcastil
Copy link
Owner

dcastil commented Jan 30, 2025

Hey @AlanMorel! 👋

Just tried to reproduce your case locally and in CodeSandbox: https://codesandbox.io/p/sandbox/vnwq59?file=%2Fsrc%2Findex.ts%3A11%2C2.

In both cases I get back the string bg-black/15 bg-linear-to-b after merging. Is this the twMerge function exported from tailwind-merge or did you configure it with extendTailwindMerge?

@AlanMorel
Copy link
Author

Hey Dany, I resolved my issue by just deleting my node_modules folder and reinstalling everything. I guess it might have still been using the old version somehow, leading to my original issue. Everything is good now on my end, apologies if I wasted your time.

Thanks so much!

@dcastil
Copy link
Owner

dcastil commented Jan 30, 2025

Ah good that it wasn't a bug in the package. No worries, this also happens to me from time to time. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context-v3 Related to tailwind-merge v3
Projects
None yet
Development

No branches or pull requests

2 participants