This package allows you to merge multiple Tailwind CSS classes and automatically resolves conflicts between them without headaches.
tailwind-merge-php is a PHP port of the excellent tailwind-merge created by dcastil.
- Supports Tailwind v3.0 up to v3.3
- First-class support for Laravel
composer require yieldstudio/tailwind-merge-php
use YieldStudio\TailwindMerge\TailwindMerge;
use YieldStudio\TailwindMerge\TailwindMergeConfig;
// Singleton
$twMerge = TailwindMerge::instance();
$twMerge->merge('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg
// Custom instance
$twMerge = new TailwindMerge(TailwindMergeConfig::default()); // Config is optional
$twMerge->merge('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg
You can publish the configuration file with:
php artisan vendor:publish --provider="YieldStudio\TailwindMerge\Laravel\TailwindMergeServiceProvider"
tw('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg
<div @tw('w-8 h-8 rounded-full rounded-lg')></div>
// will be
<div class="w-8 h-8 rounded-lg"></div>
// avatar.blade.php
<div {{ $attributes->tw('w-8 h-8 rounded-full') }}></div>
// header.blade.php
<x-avatar class="rounded-lg" />
// will be
<div class="w-8 h-8 rounded-lg"></div>
✍️ Complete documentation is being written
To run the tests, just run composer install
and composer test
.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you've found a bug regarding security please mail contact@yieldstudio.fr instead of using the issue tracker.
- James Hemery
- Special thanks to dcastil who built tailwind-merge
The MIT License (MIT). Please see License File for more information.