pskordilakis / blade-class-directive
Laravel blade class directive
Installs: 1 157
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: >=7.2
- illuminate/support: ^5.8
Requires (Dev)
- phpunit/phpunit: ^8.1
This package is auto-updated.
Last update: 2025-04-08 22:53:18 UTC
README
Inspired by classnames for react.
Installation
composer require pskordilakis/blade-class-directive
Usage
@class directive accepts a variable number of arguments that can be of type string or array and returns(prints) a class attribute for an HTML element. Any string argument will be added as part of the value of the class attribute. For the array arguments, the entries will be filtered based on the value (truthy/falsy) and the key will be added to the class value
String arguments
@class('btn btn-primary')
Array Arguments
@class([ 'btn' => true, 'btn-primary' => true, 'disabled' => $isDisabled ])
Mixed Arguments
@class('btn btn-primary', [ 'disabled' => $isDisabled ])
On HTML elements
<li @class('page-item', [ 'disabled' => $pagination->onFirstPage() ])></li>