A Phosphor icon set ready to be used as Enums in a Filament 4 application.
You can install the package via composer:
composer require tonegabes/filament-phosphor-icons
All icons are available through an enum providing convenient usage throughout your Filament app. For more information, check the Filament docs.
For all available icons check the Phosphor Icons.
use Filament\Actions\Action;use Filament\Forms\Components\Toggle;use ToneGabes\Filament\Icons\Enums\Phosphor;Â Action::make('star') ->icon(Phosphor::StarBold);Â Toggle::make('is_starred') ->onIcon(Phosphor::Star)
This package includes a enum with weights you can use:
enum Weight: string{ case Thin = 'thin'; case Light = 'light'; case Fill = 'fill'; case Duotone = 'duotone'; case Bold = 'bold'; case Regular = 'regular';}
Use it to force a certain style:
use Filament\Forms\Components\Toggle;use ToneGabes\Filament\Icons\Enums\Phosphor;use ToneGabes\Filament\Icons\Enums\Weight;Â // SimpleToggle::make('is_starred') ->onIcon(Phosphor::StarFill) ->offIcon(Phosphor::Star);Â // Forcing with enumToggle::make('is_starred') ->onIcon(Phosphor::Star->forceWeight(Weight::Fill)) ->offIcon(Phosphor::Star->forceWeight(Weight::Regular));Â // You can use 'forceWeight' to set weight based on a variableAction::make('star')->icon(Phosphor::StarBold->forceWeight($var));
For convenience, this package also comes with helper methods to improve DX and make more dynamic code:
// Overrides the default bold case to another at runtime ->icon(Phosphor::StarBold->thin()); ->icon(Phosphor::StarBold->light()); ->icon(Phosphor::StarBold->regular()); ->icon(Phosphor::StarBold->fill()); ->icon(Phosphor::StarBold->bold()); ->icon(Phosphor::StarBold->duotone());
You can also use with conditions:
// Approach 1IconColumn::make('is_favorite') ->icon(fn (string $state) => match ($state) { true => Phosphor::HeartFill, false => Phosphor::Heart, })Â // Approach 2IconColumn::make('is_favorite') ->icon(fn (string $state) => Phosphor::Heart->fill($state))
If you would like to use an icon in a Blade component, you can:
@php use ToneGabes\Filament\Icons\Enums\Phosphor;@endphp // Use it as attribute<x-filament::badge :icon="Phosphor::Star"> Star</x-filament::badge> // Use it as svg directive@svg(Phosphor::Star->getLabel()) // Use it as svg helper{{ svg(Phosphor::Star->getLabel()) }} // Use it as component<x-icon name="{{ Phosphor::Star->getLabel() }}" />
This package gives you an artisan command, so you can sync Phosphor icons from Blade icons to this package enum. It is, of course, a temporary solution in case news icons have dropped and this package is not updated yet.
php artisan phosphor:sync
The MIT License (MIT). Please see License for more information.
I build interactive platforms with Filament and Livewire. Passionate about clean code and clean UI