Laravel - Blade Templates - Conditional Classes

The @class directive conditionally compiles a CSS class string. The directive accepts an array of classes where the array key contains the class or classes you wish to add, while the value is a boolean expression. If the array element has a numeric key, it will always be included in the rendered class list:

        $isActive = false;
        $hasError = true;
        'text-gray-500' => ! $isActive,
        'bg-red' => $hasError,