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

Tailwind merge wrongly merge background-opacity with background-color. #448

Closed
ngtrthinh169TPC opened this issue Jul 22, 2024 · 2 comments · Fixed by #451
Closed

Tailwind merge wrongly merge background-opacity with background-color. #448

ngtrthinh169TPC opened this issue Jul 22, 2024 · 2 comments · Fixed by #451
Labels
bug Something isn't working context-v2 Related to tailwind-merge v2

Comments

@ngtrthinh169TPC
Copy link

ngtrthinh169TPC commented Jul 22, 2024

Describe the bug

When background-color is used with background-opacity, the latter written will be removed by tailwind-merge. This disallows any efforts to make transparent effects.

To Reproduce

https://codesandbox.io/p/sandbox/unruffled-bose-cssr35?file=%2Fsrc%2Findex.ts%3A21%2C71
image

Expected behavior

background-color and background-opacity should not collide. Both of the classes should be kept.

Environment

  • tailwind-merge version: 2.4.0
@github-actions github-actions bot added the context-v2 Related to tailwind-merge v2 label Jul 22, 2024
@ngtrthinh169TPC ngtrthinh169TPC changed the title Tailwind merge wrongly merge background-opacity with background color. Tailwind merge wrongly merge background-opacity with background-color. Jul 22, 2024
@dcastil dcastil added the bug Something isn't working label Jul 29, 2024
@dcastil
Copy link
Owner

dcastil commented Jul 29, 2024

Hey @ngtrthinh169TPC! 👋

This is indeed a bug. The problem is that tailwind-merge only accepts numbers within arbitrary values of opacities and then erroneously defaults to classify it as a background-color class. I'll fix it in the coming days.

In the meantime you can work around it by using bg-opacity-[0.48] instead. That should work without issues.

Copy link

This was addressed in release v2.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working context-v2 Related to tailwind-merge v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants