filafly/filament-icons
Composer 安装命令:
composer require filafly/filament-icons
包简介
Core package for managing Filament icon drivers via a common interface.
README 文档
README
A package to replace Filament's default Heroicons with your preferred icon set, providing unified icon management with style variations and overrides.Features
- Unified Icon Management: Standardize all icons across your Filament project.
- Style Variations: Switch between icon styles (e.g.,
solid,regular,light) with a single method call. - Granular Overrides: Override specific icons or aliases at the global or component level.
- Extensible: Easily create your own icon set implementations for any icon library with a Blade Icons package.
- Developer-Focused: Designed for developers creating icon set implementations, not just end-users.
Available Icon Sets
The following icon sets are available as separate packages that work with this core package:
Official Implementations
Community Implementations
Creating Your Own Icon Set
The best and most straightforward way to create your own set is by using the Filament Icons Template repository. Just click "use this template" and follow the instructions on the page.
If you want to create your own implementation manually, this package enables you to integrate any icon library that has a Blade Icons implementation with Filament. Here's how to get started:
Requirements
- An icon set with a Blade Icons implementation. If one doesn't exist, you'll need to create it.
- Your project must use Filament v4 or v5. For older versions, use the
1.xbranch of this package.
Implementation Steps
1. Define the Icon Enum
Create a PHP enum that defines all icons in your set. The enum cases should have styles baked into their names (e.g., SearchRegular, SearchSolid).
<?php namespace App\Enums; enum MyIcon: string { case SearchRegular = 'search'; case SearchSolid = 'search-solid'; // ... other icons }
2. (Optional) Define the Style Enum
If your icon set supports multiple styles (e.g., regular, solid, duotone), create a StyleEnum that implements Filafly\Icons\Contracts\StyleEnum. This ensures your enum provides the necessary methods for the style system.
<?php namespace App\Enums; use Filafly\Icons\Contracts\StyleEnum as StyleEnumContract; enum MyIconStyle: string implements StyleEnumContract { case Regular = 'regular'; case Solid = 'solid'; public function getStyleName(): string { return $this->value; } public function getEnumSuffix(): string { return ucfirst($this->value); } public static function getStyleNames(): array { return array_column(self::cases(), 'value'); } public static function fromStyleName(string $styleName): ?self { foreach (self::cases() as $case) { if ($case->getStyleName() === $styleName) { return $case; } } return null; } }
3. Create the IconSet Class
Create a class that extends Filafly\Icons\IconSet. This class will manage your icon set's integration with Filament.
<?php namespace App\Icons; use App\Enums\MyIcon; use App\Enums\MyIconStyle; use Filafly\Icons\IconSet; class MyIcon extends IconSet { protected string $pluginId = 'vendor-filament-my-icons'; protected string $iconPrefix = 'my-icon'; // Optional: if different from guessed prefix protected mixed $iconEnum = MyIcon::class; protected ?string $styleEnum = MyIconStyle::class; // Optional }
Icon Prefix: The system automatically guesses the icon prefix from your
$iconEnum's class name (e.g.,MyIconbecomesmyicon). If your Blade Icons package uses a different prefix, set it with$iconPrefix.
4. Map Filament Icon Aliases
In your IconSet class, map Filament's icon aliases to your icon enum cases in the $iconMap array.
protected array $iconMap = [ 'panels::global-search.field' => MyIcon::SearchRegular, 'panels::pages.dashboard.actions.filter' => MyIcon::SearchSolid, // ... other mappings ];
Advanced Usage
The IconSet class provides powerful methods for style transformations and granular overrides.
Global Styling
You can set a global style for all icons in your set. This is useful for applying a consistent look across your application.
Using the style() method:
MyIcon::make()->style('solid');
Using dynamic style methods:
If you have a StyleEnum defined, you can use dynamic methods named after your styles:
MyIcon::make()->solid(); MyIcon::make()->regular();
Granular Overrides
Overrides allow you to change icons for specific aliases or replace one icon with another. The override precedence is:
- Exact Overrides:
overrideAlias()andoverrideIcon() - Style Overrides:
overrideStyleForAlias()andoverrideStyleForIcon() - Global Style:
style()or dynamic methods - Default: The original mapping in
$iconMap
overrideAlias(string $alias, mixed $iconCase)
Overrides a specific Filament alias to use a different icon.
MyIcon::make()->overrideAlias('panels::global-search.field', MyIcon::SearchSolid);
overrideAliases(array $overrides)
Overrides multiple aliases at once.
MyIcon::make()->overrideAliases([ 'panels::global-search.field' => MyIcon::SearchSolid, 'panels::pages.dashboard.actions.filter' => MyIcon::SearchRegular, ]);
overrideIcon(mixed $fromIconCase, mixed $toIconCase)
Replaces one icon enum case with another across all its uses.
MyIcon::make()->overrideIcon(MyIcon::SearchRegular, MyIcon::SearchSolid);
overrideIcons(array $overrides)
Replaces multiple icons at once.
MyIcon::make()->overrideIcons([ MyIcon::SearchRegular => MyIcon::SearchSolid, ]);
overrideStyleForAlias(string|array $aliases, string|object $style)
Applies a specific style to one or more aliases.
MyIcon::make()->overrideStyleForAlias('panels::global-search.field', 'solid'); // or MyIcon::make()->overrideStyleForAlias(['panels::global-search.field'], MyIconStyle::Solid);
overrideStyleForIcon(mixed $iconCases, string|object $style)
Applies a specific style to one or more icon enum cases.
MyIcon::make()->overrideStyleForIcon(MyIcon::SearchRegular, 'solid'); // or MyIcon::make()->overrideStyleForIcon([MyIcon::SearchRegular], MyIconStyle::Solid);
License
The MIT License (MIT). Please see License File for more information.
filafly/filament-icons 适用场景与选型建议
filafly/filament-icons 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 77.17k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「icons」 「replace」 「carbon」 「font awesome」 「swap」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 filafly/filament-icons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 filafly/filament-icons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 filafly/filament-icons 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Replace image URLs found in HTML
Provides a Composer script to project skeleton hydration by placeholders replacements.
A simple library of SVG page type icons for enhancing your SilverStripe CMS interface.
A Filament plugin that integrates tabler icons, allowing you to use them seamlessly across Filament forms, tables, actions, and more.
Adds PHP's preg_replace function as a Twig filter.
Font Awesome icon pack for Filament Icons
统计信息
- 总下载量: 77.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 29
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-30