information overload

by sebastian de deyne

TailwindMerge for Laravel

10 Jul 2024 via github.com

I’ve been writing more Blade + Tailwind the past few weeks. Coming from React + Tailwind I really missed tailwind-merge and clsx, but luckily came across this great package from Sandro Gehri.

{{-- components/button.blade.php --}}
<button
    {{ $attributes
        ->merge(['type' => 'submit'])
        ->twMerge('bg-green-500') }}
>
    {{ $slot }}
</button>

{{-- home/index.blade.php --}}
<x-button class="bg-red-500">
    A red button
</x-button>

Source code and installation instructions on GitHub.