marcw / twig-heroicons
Unofficial Twig integration for Heroicons
Installs: 10 407
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 5
Open Issues: 2
Requires
- twig/twig: ^3.3
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/framework-bundle: ^5.0
README
This package provides an Heroicons integration for Twig.
Install
Use composer:
composer require marcw/twig-heroicons
Symfony
You do not need to do anything more to use the extension.
Twig
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());
Usage
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') }}
License
This library is MIT licensed.