Gumbraise / twig-heroicons

Heroicons V2.0.18 <3 Twig

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twig Heroicons

tests

This package provides a Heroicons integration for Twig.

Install

Use composer:

composer require gumbraise/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, style, options) }}

{# the default style is 'solid' #}
{{ heroicon('academic-cap') }}

{# use the 'outline' style #}
{{ heroicon('academic-cap', 'outline') }}

{# use the 'mini' style #}
{{ heroicon('academic-cap', 'mini') }}

{# Add a custom class to the SVG #}
{{ heroicon('academic-cap', 'outline', {
    'class': "text-green-200",
}) }}

Supported Options

You can add several options at the same time.

  • Class
    {{ heroicon(icon, style, {
      'class': '...'  
    }) }}
  • Stroke
    {{ heroicon(icon, style, {
      'stroke': '#......'  
    }) }}
  • Stroke Width
    {{ heroicon(icon, style, {
      'stroke-width': '...'  
    }) }}
  • Fill
    {{ heroicon(icon, style, {
      'fill': '#......'  
    }) }}

License

This library is MIT licensed.

About

Heroicons V2.0.18 <3 Twig

License:MIT License


Languages

Language:PHP 96.2%Language:Makefile 3.8%