New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

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
Laravel:5
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
yamadashy/laravel-blade-minify-directive

@minify directive to partially compress HTML.

1,431 7
tungpham42/laravel-blade-minify-directive

@minify directive to partially compress HTML.

6 1
balping/laravel-blade-function

This Laravel 5.1+ package lets you declare functions inside blade templates.

10,658 21
spatie/laravel-blade-javascript

A Blade directive to export variables to JavaScript

1,001,484 619

Version History

Version Released PHP Laravel License
v1.0.1 >=7.2 ^5.8 MIT
v1.0.0 >=7.2 ^5.8 MIT