fawaziwalewa/filament-icon-picker
Installation
composer require fawaziwalewa/filament-icon-picker
Publish the config (if needed):
php artisan vendor:publish --provider="FawaziWalewa\FilamentIconPicker\FilamentIconPickerServiceProvider"
First Use Case Add the field to a Filament form/resource:
use FawaziWalewa\FilamentIconPicker\Fields\IconPicker;
IconPicker::make('icon')
->iconSets(['heroicons', 'lucide'])
->required()
Where to Look First
config/filament-icon-picker.php (for global defaults)iconSets(), searchable(), and columns() methodsdocs/ folder for screenshots and examplesBasic Icon Selection
IconPicker::make('icon')
->iconSets(['heroicons:solid', 'lucide:outline'])
->default('heroicons:home')
Multi-Column Layout
IconPicker::make('icon')
->columns(4) // Adjusts grid layout
->searchable() // Enables search bar
Dynamic Icon Sets
// Load sets dynamically based on user role
IconPicker::make('icon')
->iconSets(fn() => auth()->user()->can('admin') ? ['heroicons', 'lucide', 'font-awesome'] : ['heroicons', 'lucide'])
Integration with Filament Tables
// Display icons in a table column
use FawaziWalewa\FilamentIconPicker\Columns\IconColumn;
IconColumn::make('icon')
->iconSets(['heroicons', 'lucide'])
->size('sm') // Optional: 'xs', 'sm', 'md', 'lg'
Custom Icon Sets
// Register a custom icon set (e.g., from a CDN)
IconPicker::make('icon')
->iconSets([
'custom' => [
'path' => 'https://cdn.example.com/icons',
'prefix' => 'custom-',
'icons' => ['home', 'settings', 'user'],
],
]);
Validation & Rules
IconPicker::make('icon')
->rules([
Rule::required(),
Rule::in(['heroicons:home', 'lucide:settings']),
])
IconPicker::make('icon')
->iconSets(config('filament-icon-picker.sets.admin'))
use FawaziWalewa\FilamentIconPicker\Components\IconPickerWidget;
IconPickerWidget::make('custom_icon')
->iconSets(['heroicons'])
->extraAttribute('data-custom', 'value');
Icon Set Not Found
heroicon vs heroicons).config/filament-icon-picker.php or use dd(FilamentIconPicker::getAvailableSets()) to debug.Icons Not Loading
public_path() in custom sets.'path' => public_path('vendor/icons'),
filament-icon-picker:assets is published if using custom assets.Search Not Working
searchable() not called or Alpine.js conflict.livewire:ignore block if needed:
<div x-data x-ignore>
{{ $this->iconPicker }}
</div>
Performance with Large Sets
IconPicker::make('icon')
->iconSets(['heroicons:solid' => ['home', 'settings']]) // Subset
dd(FilamentIconPicker::getAvailableSets());
F12) and check the Alpine store for iconPicker data.Custom Icon Rendering Override the default icon rendering in a service provider:
FilamentIconPicker::macro('renderIcon', function ($icon, $size = 'md') {
return "<svg>...</svg>"; // Custom SVG
});
Add New Icon Sets
Extend the IconSet class or publish the config:
// config/filament-icon-picker.php
'sets' => [
'custom' => [
'path' => 'https://cdn.example.com',
'prefix' => 'custom-',
'icons' => ['icon1', 'icon2'],
],
],
Localization Translate labels/placeholders via Filament’s localization system:
IconPicker::make('icon')
->label(__('filament-icon-picker::fields.icon.label'))
->placeholder(__('filament-icon-picker::fields.icon.placeholder'))
heroicons and lucide pre-configured. Disable them in config if not needed:
'enabled_sets' => ['heroicons:solid', 'lucide:outline'],
php artisan filament-icon-picker:assets to publish JS/CSS if customizing styles.'search_debounce' => 300, // ms
@foreach(config('filament-icon-picker.sets.heroicons.icons') as $icon)
<link rel="preload" href="{{ asset("vendor/filament-icon-picker/icons/{$icon}.svg") }}" as="image">
@endforeach
How can I help you explore Laravel packages today?