Skip to main content
Back to packages
341 GitHub stars

gehrisandro/tailwind-merge-laravel

View on GitHub

Description

Automatically resolves Tailwind CSS class conflicts in Laravel

Create your Blade components as you normally would, but instead of specifying the class attribute directly, use the mergeClasses method:

// circle.blade.php
<div {{ $attributes->twMerge('w-10 h-10 rounded-full bg-red-500') }}></div>

Now you can use your Blade components and pass additional classes to merge:

// your-view.blade.php
<x-circle class="bg-blue-500" />

This will render the following HTML:

<div class="w-10 h-10 rounded-full bg-blue-500"></div>

Note: Usage of $attributes->merge(['class' => '...']) is currently not supported due to limitations in Laravel.

Recent Courses on Laravel Daily