dcastil /tailwind-merge
Merge Tailwind CSS classes without style conflicts
★ 5,704⑂ 113👁 11⑃ 402● 233▤ 67
+1
Daily
5,704
stars
113
forks
11
watchers
402
prs
233
issues
67
releases
README
tailwind-merge
Utility function to efficiently merge Tailwind CSS classes in JS without style conflicts.
ts
import { twMerge } from 'tailwind-merge'
twMerge('px-2 py-1 bg-red hover:bg-dark-red', 'p-3 bg-[B91C1C]')
// → 'hover:bg-dark-red p-3 bg-[B91C1C]'
- Supports Tailwind v4.0 up to v4.3 (if you use Tailwind v3, use tailwind-merge v2.6.0)
- Works in all modern browsers and maintained Node versions
- Fully typed, with published declarations compatible with TypeScript 3.8 and newer
- Check bundle size on Bundlephobia
Get started
- What is it for
- When and how to use it
- Features
- Limitations
- Configuration
- Recipes
- API reference
- Writing plugins
- Versioning
- Contributing
- Similar packages
Packages in this repository
This repository is a monorepo. The docs above belong to the tailwind-merge package — what most visitors are here for — and everything package-specific (source, docs, changelog) lives in the package directories.
| Package | Description |
| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| tailwind-merge (npm) | The library itself — see the docs above. |
| @tailwind-merge/vite | Automatic theme configuration and source-based pruning for Vite apps. No stable release yet; dev builds on npm under the dev tag. |
| @tailwind-merge/next | The same for Next.js apps, with Turbopack and webpack. No stable release yet; dev builds on npm under the dev tag. |
| @tailwind-merge/configurator | JavaScript API and CLI for generating a theme-specific merge module. Unreleased; API remains unstable. |
| @tailwind-merge/plugin-core | Shared internals of the Vite and Next.js plugins (discovery, generation, refresh). Unpublished; inlined into both plugins. |Top issues
#594Support for translate-* utilities in Tailwind CSS v4 (missing implicit transform behavior)5 comments · 2025-07-04#553composite class does not merge with individual class5 comments · 2025-03-24#377Custom spacing without "full" does not merge while "auto" does4 comments · 2024-02-09#357Get Tailwind Arbitrary Value4 comments · 2023-12-19#668pnpm flagging a trust downgrade in tailwind-merge3 comments · 2026-04-01#630Define `tailwindcss` version in `peerDependencies`3 comments · 2026-01-08#573leading classes are getting removed if applied in the middle3 comments · 2025-05-01#385Expose low-level API to use tailwind-merge logic for custom use cases3 comments · 2024-03-03
Discussions
#649Is there any tailwind merge configuration that can merge both non prefixed class and prefixed class?1 comments · 2026-02-02#628Feature request: Add a “responsive reset” behavior to allow overriding all breakpoint variants of a class group2 comments · 2025-11-26#627Significant Performance Improvement with only a few lines of code1 comments · 2025-11-24#600On the topic of prefixes1 comments · 2025-08-09#587cant resolve my custom prefixed ui:bg-black/6 with bg-black/31 comments · 2025-06-06#586make twMerge take into account different then the orignal class order definition1 comments · 2025-06-01#584can't resolve family-name and font-weight when using arbitrary values, last one wins1 comments · 2025-05-30#582Custom gap classes1 comments · 2025-05-27
Latest release
[email protected] [email protected] 2026-09-12New Features - Prepare some upcoming changes by @dcastil in https://github.com/dcastil/tailwind-merge/pull/713 - Theme getters returned by fromTheme now expose the theme key they read as a themeKey property, so tooling can identify the referenced theme scale without calling the getter. - Release tags now include the package name, starting with [email protected]. Bug Fixes - Fix arbitrary values using color() or light-dark() being classified as lengths instead of colors by @ddussi in https://github.com/dcastil/tailwind-merge/pull/712 - Fix bare bg-conic not merging with othe