marcw/twig-heroicons

Unofficial Twig integration for Heroicons

1.0.1 2021-04-10 14:39 UTC

This package is auto-updated.

Last update: 2024-11-16 15:05:20 UTC


README

tests

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.