webagil-kevin/twig-heroicons

Heroicons 的非官方 Twig 集成

v2.1 2023-12-31 15:19 UTC

This package is auto-updated.

Last update: 2024-09-30 01:38:16 UTC


README

tests

此包为 Twig 提供了 Heroicons 集成。

安装

使用 Composer

composer require webagil-kevin/twig-heroicons

Symfony

使用此扩展无需进行更多操作。

Twig

如果直接使用 Twig,在使用之前注册扩展

<?php

use Webagil\Heroicons\Twig\HeroiconsExtension;
use Twig\Environment;

$twig = new Environment(/* ... */);
$twig->addExtension(new HeroiconsExtension());

用法

此扩展提供了一个 heroicon 函数,用于输出图标 SVG。

{# function signature #}
{{ heroicon(icon, class, style) }}

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

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

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

4 种图标样式: solidoutlineminimicro

许可证

此库采用 MIT 许可证。

致谢

此项目是 marcw/twig-heroicons 仓库的分支。

分支此项目的目的是更新项目,并保持与最新版本的 Symfony 和 Heroicons 的兼容性。我们非常感激原始项目所付出的努力和工作。

有关原始项目的信息,请参阅原始仓库。