New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

goodm4ven/tailwind-merge

Resolves TailwindCSS class conflicts in between Laravel Blade component calls
1,792 1
Install
composer require goodm4ven/tailwind-merge
Latest Version:v1.1.10
PHP:^8.4||^8.3
Laravel:11 · 12
License:MIT
Last Updated:Apr 20, 2026
Links: GitHub  ·  Packagist
Maintainer: GoodM4ven
بسم الله الرحمن الرحيم

Tailwind Merge

Latest Version on Packagist GitHub Tests Action Status Coverage Status Total Downloads

Dealing with TailwindCSS classes overriding can either be done with fighting important (!) classes, OR by using this package to remove the conflicting ones from the targetted component and keep the outside (passed) one instead.

Installation

Install the package with Composer:

composer require goodm4ven/tailwind-merge

Usage

It's all about the last-wins approach for consistency. Single string or multiple ones are around as arguments. You may also add them as an associative array to conditions!

  • Global helper function for PHP anywhere
twMerge('text-lg text-sm'); // results in "text-sm"
twMerge('sm:text-lg', 'sm:text-3xl'); // results in "sm:text-3xl"
twMerge([
    'sm:text-lg py-10 px-5' => true,
    'sm:text-xl' => false,
    'sm:text-3xl py-5',
    'sm:text-sm' => true,
]); // results in "sm:text-sm px-5 py-5"
  • Resolve the merger directly (container or facade)
// Either
app('tailwind-merge')->classes('last conflicting classes win');
// Or
\GoodMaven\TailwindMerge\TailwindMerge::classes('last conflicting classes win');
  • Attribute bag macro inside Laravel Blade components
$attributes->twMerge('last conflicting classes win', 'then last conflicting classes win');
  • Blade directive for Blade views in general
@twMerge('last conflicting classes win')

Development

This package was initiated based on my Laravel package template that is built on top of Spatie's. Make sure to read the docs for both.

Support

Support ongoing package maintenance as well as the development of other projects through sponsorship or one-time donations if you prefer.

Credits


والحمد لله رب العالمين

Related Packages

yieldstudio/tailwind-merge-php

Merge Tailwind CSS classes without style conflicts

77,611 49
tonysm/tailwindcss-laravel

This package wraps up the standalone executable version of the Tailwind CSS fram...

15,739 263
laravel-frontend-presets/tailwindcss

Laravel frontend preset for Tailwind CSS

416,639 1,149
miaababikir/laravel-tailwind-dashboard-preset

Laravel tailwind css dashboard preset

4,783 359
xndbogdan/tailwindcss

Laravel frontend preset for Tailwind CSS

1,952 3

Version History

Version Released PHP Laravel License
v1.1.10 ^8.4||^8.3 ^11.0||^12.0 MIT
v1.1.9 ^8.4||^8.3 ^11.0||^12.0 MIT
v1.1.8 ^8.4||^8.3 ^11.0||^12.0 MIT
v1.1.7 ^8.4||^8.3 ^11.0||^12.0 MIT
v1.1.6 ^8.4||^8.3 ^11.0||^12.0 MIT