pskordilakis/blade-class-directive
Laravel blade class directive
1,158
4
| Install | |
|---|---|
composer require pskordilakis/blade-class-directive |
|
| Latest Version: | v1.0.1 |
| PHP: | >=7.2 |
| License: | MIT |
| Last Updated: | Jan 8, 2025 |
| Links: | GitHub · Packagist |
Maintainer: pskordilakis
Blade Class Directive
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>
Related Packages
devmcc/blade-extended
Expands the blade functionality of the Laravel framework with additional directi...
19
0
balping/laravel-blade-function
This Laravel 5.1+ package lets you declare functions inside blade templates.
10,566
21