tailwind-merge combines Tailwind CSS class strings in JavaScript or TypeScript without style conflicts, supporting recent Tailwind v4 releases.
Overview
tailwind-merge provides a utility function that merges Tailwind utility class lists the way authors expect when conditional styles overlap. It understands Tailwind's conflict rules so later classes win without leaving contradictory utilities applied.
The package targets modern browsers and maintained Node versions with TypeScript declarations for current TypeScript releases. Related monorepo packages explore Vite and Next.js integrations and theme-specific configurators still under development.
Developers call the merge helper anywhere they compose className strings in React or other frameworks using Tailwind.
Key features
- Tailwind conflict resolution
- TypeScript typings
- Tailwind v4 support
- Browser and Node usage
- Framework agnostic API
- Configurable theme hooks
- Companion Vite plugin preview
- Next.js plugin preview
Use cases
- Conditional React classNames
- Component variant styling
- Design system utilities
- Avoiding conflicting utilities