Use TailwindMerge in Laravel Blade Components
mainTo allow overriding classes in Blade components, use the $attributes->twMerge() method inside your component template. This resolves conflicts by ensuring classes passed from the parent view take precedence over the component's default classes.
Note: Do not use $attributes->merge(['class' => '...']) as it is not supported due to Laravel limitations.
Example: Basic Component
Component (circle.blade.php):
<div {{ $attributes->twMerge('w-10 h-10 rounded-full bg-red-500') }}></div>Usage (your-view.blade.php):
<x-circle class="bg-blue-500" />Output:
<div class="w-10 h-10 rounded-full bg-blue-500"></div>// circle.blade.php
<div {{ $attributes->twMerge('w-10 h-10 rounded-full bg-red-500') }}></div>