This package provides an Heroicons integration for Twig.
Use composer:
composer require marcw/twig-heroicons
You do not need to do anything more to use the extension.
If you use Twig directly, register the extension before using it:
<?php
use MarcW\Heroicons\Twig\HeroiconsExtension;
use Twig\Environment;
$twig = new Environment(/* ... */);
$twig->addExtension(new HeroiconsExtension());
This extension provides a heroicon
function that outputs the icon SVG.
{# function signature #}
{{ heroicon(icon, class, style) }}
{# the default style is 'solid' #}
{{ heroicon('academic-cap') }}
{# use the 'outline' style #}
{{ heroicon('academic-cap', '', 'outline') }}
{# Add a custom class to the SVG #}
{{ heroicon('academic-cap', 'text-green-200', 'outline') }}
This library is MIT licensed.