Handy Blade directives

1.14.0 2023-06-14 09:08 UTC


Latest Version on Packagist Total Downloads Software License Build Status

A collection of nice Laravel Blade directives.


You can install the package via composer:

composer require appstract/laravel-blade-directives



Only show when $variable isset and true.

   This will be echoed

Or when you would like to quickly echo

@istrue($variable, 'This will be echoed')


Same as @istrue but checks for isset and false.

   This will be echoed


Only show when $variable is null.

   This will be echoed


Same as @isnull but one shows when $variable is not null.

   This will be echoed

@dump and @dd




Create a HTML element to your Laravel-Mix css or js.



<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
<script src="{{ mix('/js/app.js') }}"></script>


Create a <style> element or <link> element with a css path.

    body { background: black }



Create a <script> element with or without a js path.

    alert('hello world')



Load the contents of a css or js file inline in your view.



Same as @push but will include content one time only. Useful for repeatable blocks.

First parameter must follow the syntax stack-name:group-name.

    <script src="{{ asset('/js/foobar.js') }}"></script>

Include pushes with standard @stack directive:



Checks if the current route name is equal to the given parameter. You can use a wildcard like*.

    Do something only on the checkout


Checks if the current route name is not equal to the given parameter. You can use a wildcard like*

    Do something only if this is not the checkout


Checks if the first parameter is an instance of the second parameter.

@instanceof($user, 'App\User')
    User is an instance of App\User


Checks if the parameter is of a certain type.

@typeof($text, 'string')
    Text is a string


Repeat something a specified amount of times.

    Iteration #{{ $iteration }}

@fa, @fas, @far, @fal, @fab, @fad, @mdi, @glyph

Quickly output an icon with Font Awesome, Material Design Icons or Glyphicon.

@fa('address-book', 'optional-extra-class')

// for Font Awesome 5 (solid, regular, light, brand, duotone):
@fas('address-book', 'optional-extra-class')
@far('address-book', 'optional-extra-class')
@fal('address-book', 'optional-extra-class')
@fab('address-book', 'optional-extra-class')
@fad('address-book', 'optional-extra-class')

// for Material Design Icons
@mdi('account', 'optional-extra-class')

// for Glyphicons
@glyph('glass', 'optional-extra-class')


Output data-attributes from an array.

@data(['testing' => 123])


Quickly output for classical $errors->has('input_name') to determine if any error messages exist for a given field.

    This input has an error


Output number of entries.



Replaces \n into <br>.

@nl2br('foo\n bar\n baz\n')

@snake, @kebab, @camel

Output formatted string (uses Laravel Helpers).

// output: 'foo_bar'

// output: 'foo-bar'

@camel('foo bar')
// output: 'fooBar'


composer test


Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.


The MIT License (MIT). Please see License File for more information.