# tailwind-merge

> Merge Tailwind CSS classes without style conflicts

Source: https://talira.ai/catalog/tailwind-merge-qq4njz01
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [frontend / css / class merging](https://talira.ai/categories/frontend/css/class-merging)
- Licence: MIT[^2]
- Pricing: Free and open source[^2]
- Pricing notes: Free and open source under MIT.
- Free tier: yes[^2]
- Self-hostable: yes
- Plugins: yes[^3]
- Backed by: [Dany Castillo](https://talira.ai/orgs/dany-castillo.md)
- Creator: Dany Castillo

tailwind-merge is a JavaScript utility, `twMerge`, that joins [Tailwind CSS](https://talira.ai/catalog/tailwind-css-wfchsr5n.md) class strings and removes the ones that conflict, so the last conflicting class wins: `twMerge('px-2 py-1 bg-red', 'p-3 bg-[#B91C1C]')` keeps only `p-3 bg-[#B91C1C]`. It understands modifiers and stacked variants, arbitrary values, properties and variants, the important modifier and custom colours, keeps classes that aren't Tailwind's, accepts conditional classes and arrays, and caches results. It's typically used when a component accepts a `className` prop that should override its own classes. Version 3 supports Tailwind CSS v4.0 to v4.3, with v2.6.0 for Tailwind v3; it can be configured or extended with plugins for custom themes, is fully typed and MIT-licensed, and is made by Dany Castillo.

## Links

- GitHub: https://github.com/dcastil/tailwind-merge
- Docs: https://github.com/dcastil/tailwind-merge/tree/main/packages/tailwind-merge/docs

## Problems it solves

- when I pass a className to my React component its Tailwind classes clash with the component's defaults
- p-3 and px-2 both end up on the element and the wrong padding wins
- let callers override a component's background or spacing classes without a pile of conditionals
- combine conditional Tailwind classes and drop the ones that conflict
- dedupe Tailwind classes with hover: and md: modifiers correctly
- merge Tailwind classes that use arbitrary values like bg-[#B91C1C]
- teach a class merging utility about the custom scales in my Tailwind theme

## Features

- last conflicting class wins, including non-trivial conflicts between shorthand and longhand utilities
- modifiers, stacked modifiers, postfix modifiers and the important modifier
- arbitrary values (with type detection), arbitrary properties and arbitrary variants
- keeps non-Tailwind classes and supports custom colours out of the box
- multiple arguments, conditional classes and nested arrays
- cached results, reused data structures and lazy initialisation
- configuration and plugins for custom Tailwind themes
- fully typed
- supports Tailwind CSS v4.0 to v4.3; v2.6.0 for Tailwind v3

## Limitations

- Doesn't tell custom classes apart from Tailwind ones that look the same: a custom text-2xs is merged as a font size[^1]

## Capabilities

- Takes plugins: plan not known

## Trust

Overall: 0.72 out of 1.
Signals: maintenance 1.00, adoption 0.75, momentum 0.59, community 0.69, backing 0.50, extensibility 0.20.

- last commit 4 days ago
- 243 commits in the last 90 days
- latest release tailwind-merge@3.7.1 4 days ago
- 5.7k GitHub stars
- 52 contributors
- accepts sponsorship (Github)
- backed by Dany Castillo
- created by Dany Castillo
- has a plugin system

## Related

- Works with [Tailwind CSS](https://talira.ai/catalog/tailwind-css-wfchsr5n.md)

## Sources

[^1]: https://github.com/dcastil/tailwind-merge/blob/main/packages/tailwind-merge/docs/limitations.md (checked 23 Nov 2026)
[^2]: https://github.com/dcastil/tailwind-merge/blob/main/LICENSE.md (checked 23 Nov 2026)
[^3]: https://github.com/dcastil/tailwind-merge/blob/main/packages/tailwind-merge/docs/writing-plugins.md (checked 23 Nov 2026)
