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
Marketing for Developers in 2026
7 lessons
52 min
Roles and Permissions in Laravel 13
14 lessons
57 min
Testing in Laravel 13 For Beginners
26 lessons
1 h 41 min read