goodm4ven/tailwind-merge

Resolves conflicting TailwindCSS classes in Laravel Blade components

Fund package maintenance!
GoodM4ven

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/goodm4ven/tailwind-merge

v1.0.2 2025-11-15 07:20 UTC

This package is auto-updated.

Last update: 2025-11-24 07:45:04 UTC


README

Latest Version on Packagist GitHub Tests Action 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

You can install the package via 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
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')

Testing

composer test

Credits