| Install | |
|---|---|
composer require fawaziwalewa/filament-icon-picker |
|
| Latest Version: | v0.1.0 |
| PHP: | ^8.2 |
Sponsored by Tasklemon.
A beautiful, searchable icon picker field for FilamentPHP v5, built with Livewire and Alpine.js. Select from multiple icon sets including Heroicons, Lucide, and more.
Install the package via Composer:
composer require fawaziwalewa/filament-icon-picker
Optional (recommended):
php artisan vendor:publish --tag="filament-icon-picker-config"
Optional (only if you want to override the UI):
php artisan vendor:publish --tag="filament-icon-picker-views"
The configuration file (config/filament-icon-picker.php) controls:
sets)columns)searchable)placeholder)Heroicons, Lucide, Font Awesome, and Bootstrap Icons are bundled as Composer dependencies of this package.
use FawazIwalewa\FilamentIconPicker\Forms\Components\IconPicker;
IconPicker::make('icon')
->label('Icon')
->required();
Sets are referenced by their config keys (from filament-icon-picker.icon_sets):
IconPicker::make('icon')
->sets(['heroicons', 'lucide', 'bootstrap']);
IconPicker::make('icon')
->gridColumns(8)
->searchable(true)
->placeholder('Pick an icon');
The selected icon is always shown as the field prefix icon using Filament's input wrapper styling.
->prefixIcon(...) on this field.IconPicker::prefixIcon() is intentionally not supported and will throw.The selected value is stored as a string (e.g. heroicon-o-user, lucide-alarm-clock, bi-alarm, fas-user).
use Filament\Tables\Columns\TextColumn;
TextColumn::make('name')
->icon(fn ($record) => $record->icon);
@php
$html = rescue(fn () => svg($record->icon, 'h-6 w-6')->toHtml(), '');
@endphp
@if (filled($html))
{!! $html !!}
@endif
If you have existing database values saved as fa-solid-* / fa-regular-* / fa-brands-*, normalize them to fas-* / far-* / fab-* when reading/writing:
use FawazIwalewa\FilamentIconPicker\Services\IconService;
use Illuminate\Database\Eloquent\Casts\Attribute;
protected function icon(): Attribute
{
return Attribute::make(
get: fn (?string $value): ?string => IconService::normalizeIconName($value),
set: fn (?string $value): ?string => IconService::normalizeIconName($value),
);
}
web + auth middleware and throttled.php artisan filament-icon-picker:list
Filter by set key:
php artisan filament-icon-picker:list --set=heroicons
Search:
php artisan filament-icon-picker:list --search=user
Export:
php artisan filament-icon-picker:list --json > icons.json
php artisan test
See CHANGELOG.
See CONTRIBUTING.
See SECURITY.
The MIT License (MIT). Please see License File for more information.