Create small, file-specific, macros in Blade like Twig has.

1.1.0 2024-03-18 10:39 UTC

This package is auto-updated.

Last update: 2024-06-18 11:06:28 UTC


Blade Macro

Latest Version on Packagist

Have you as a Laravel developer ever looked at Twig macros with envy?

Maybe you want to reuse a specific element twice on the same page, but you don't want to have it (supported) as a Blade component. With a Blade macro, you can. Here is an example:

<li class="flex justify-center all-sorts-of-tailwind-classes"> {{ $name }} </li>

        @foreach($listOne as $name)
            @showMacro(listItem, ['name' => $name])
        @foreach($listTwo as $name)
            @showMacro(listItem, ['name' => $name])


Via Composer

$ composer require jeroen-g/blade-macro


Define a macro with the Blade directives:

<fancy-code />

Call the macro elsewhere in the same Blade file with the Blade directive or PHP helper:

// or
{!! m('myMacroName') !!}

Do you want to use a macro in another Blade view? Use a Blade component.

Change log

Please see the changelog for more information on what has changed recently.


Please see for details and a todolist.



MIT. Please see the license file for more information.