Blade @class Directive Example
@php $isActive = false; $hasError = true; @endphp <span @class([ 'p-4', 'font-bold' => $isActive, 'text-gray-500' => ! $isActive, 'bg-red' => $hasError, ])></span> <span class="p-4 text-gray-500 bg-red"></span>
Learn what Laravel Blade @class directive is and how to use it to conditionally comile class into string
Created on Jul 23, 2021
•517 views
@php $isActive = false; $hasError = true; @endphp <span @class([ 'p-4', 'font-bold' => $isActive, 'text-gray-500' => ! $isActive, 'bg-red' => $hasError, ])></span> <span class="p-4 text-gray-500 bg-red"></span>
If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️
Load comments for Laravel Blade @class Directive
Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.
View Components1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago