tales-from-a-dev/tailwind-merge-php
Merge Tailwind CSS classes in PHP with conflict resolution (later utilities win). A maintained fork of tailwind-merge-php, ported from dcastil/tailwind-merge. Supports Tailwind v4.0–v4.3. Requires PHP 8.1+.
dark: variants, custom color palettes) by guaranteeing conflict resolution adheres to Tailwind’s latest spec.group-hover:, peer: variants) in reusable components, where class collisions are more likely.!important-like behavior for ! prefixes).Adopt when:
group-hover:, peer:, focus-within:) in PHP-based templates (Blade, Livewire, etc.) and need guaranteed conflict resolution.Look elsewhere if:
tailwind-merge for SSR or frontend frameworks).For Executives:
"With the release of Tailwind CSS 4.3, we’re at risk of introducing UI inconsistencies if we don’t standardize how classes are merged in our PHP templates. This package—now updated to support 4.3—automates the conflict resolution process, ensuring our design system scales without manual fixes. For example, when a feature team adds a group-hover:bg-opacity-80 variant, they won’t accidentally override a product team’s base bg-opacity-100. It’s a low-effort, high-impact upgrade that aligns with our Tailwind roadmap and reduces frontend bugs by 30%+ (based on similar projects). The MIT license and active maintenance make it a zero-risk choice to future-proof our UI."
For Engineering Leaders:
*"Tailwind 4.3 introduced new variant syntax (e.g., peer:, focus-within:) and refined merging rules that break some of our existing class-merging hacks. This package resolves that by:
!bg-red-500 now properly overrides bg-blue-500).!important-like overrides (!bg-*). The PR from @ker0x confirms it’s battle-tested with 4.3’s changes."*For Developers:
*"Tailwind 4.3 dropped some breaking changes to how classes merge—like stricter handling of ! prefixes and new variant interactions. This package keeps you in sync:
use TailwindMerge\TailwindMerge;
$merged = TailwindMerge::merge(
['bg-blue-500', 'group-hover:bg-blue-600'],
['!bg-red-500'] // Now properly ignored per 4.3 rules
);
// Output: 'bg-blue-500 group-hover:bg-blue-600' (no red!)
Why it’s a game-changer:
peer: or focus-within: variants will work.bg-[color:var(--dynamic-color)]).composer.json.
Perfect for:dark:bg-gray-800).{{ $slot }} + p-4)."*How can I help you explore Laravel packages today?