PHP code example of wallacemartinss / filament-icon-picker
1. Go to this page and download the library: Download wallacemartinss/filament-icon-picker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wallacemartinss / filament-icon-picker example snippets
use Wallacemartinss\FilamentIconPicker\Enums\Heroicons;
use Wallacemartinss\FilamentIconPicker\Enums\GoogleMaterialDesignIcons;
use Wallacemartinss\FilamentIconPicker\Enums\PhosphorIcons;
// In navigation icon (with full autocomplete!):
protected static string|BackedEnum|null $navigationIcon = GoogleMaterialDesignIcons::AccountCircle;
// In actions:
Action::make('star')->icon(Heroicons::OutlinedStar)
// In pages:
public static function getNavigationIcon(): ?string
{
return PhosphorIcons::WhatsappLogoDuotone->value;
}
use Wallacemartinss\FilamentIconPicker\Enums\Icon;
// Navigation icon:
public static function getNavigationIcon(): ?string
{
return Icon::material('account-circle');
}
// With variants:
Icon::heroicon('users', 'outlined') // heroicon-o-users
Icon::heroicon('users', 'solid') // heroicon-s-users
Icon::phosphor('whatsapp-logo', 'duotone') // phosphor-whatsapp-logo-duotone
Icon::fontawesome('heart', 'solid') // fas-heart
Icon::fontawesome('github', 'brands') // fab-github
use Wallacemartinss\FilamentIconPicker\Forms\Components\IconPickerField;
public static function form(Form $form): Form
{
return $form
->schema([
IconPickerField::make('icon')
->label('Select an Icon')
->searchable()
->
use Wallacemartinss\FilamentIconPicker\Tables\Columns\IconPickerColumn;
public static function table(Table $table): Table
{
return $table
->columns([
IconPickerColumn::make('icon')
->label('Icon'),
]);
}
IconPickerColumn::make('icon')
->size('lg') // xs, sm, md, lg, xl, 2xl
// Or use shortcut methods:
IconPickerColumn::make('icon')->extraSmall() // xs
IconPickerColumn::make('icon')->small() // sm
IconPickerColumn::make('icon')->medium() // md (default)
IconPickerColumn::make('icon')->large() // lg
IconPickerColumn::make('icon')->extraLarge() // xl
IconPickerColumn::make('icon')
->color('success') // primary, secondary, success, warning, danger, info
// Or use shortcut methods:
IconPickerColumn::make('icon')->primary()
IconPickerColumn::make('icon')->success()
IconPickerColumn::make('icon')->warning()
IconPickerColumn::make('icon')->danger()
IconPickerColumn::make('icon')->info()
// Or use CSS color values:
IconPickerColumn::make('icon')->color('#ff5500')
IconPickerColumn::make('icon')->color('rgb(255, 85, 0)')
IconPickerColumn::make('icon')->color('purple')
// Or use custom Tailwind classes:
IconPickerColumn::make('icon')->color('text-purple-500')
use Wallacemartinss\FilamentIconPicker\Enums\Heroicons;
use Wallacemartinss\FilamentIconPicker\Enums\GoogleMaterialDesignIcons;
class UserResource extends Resource
{
protected static string|BackedEnum|null $navigationIcon = GoogleMaterialDesignIcons::AccountCircle;
}
use Wallacemartinss\FilamentIconPicker\Enums\PhosphorIcons;
use Wallacemartinss\FilamentIconPicker\Enums\Icon;
// Using generated enum:
public static function getNavigationIcon(): ?string
{
return PhosphorIcons::WhatsappLogoDuotone->value;
}
// Or using Icon helper (no generation needed):
public static function getNavigationIcon(): ?string
{
return Icon::phosphor('whatsapp-logo', 'duotone');
}
use Wallacemartinss\FilamentIconPicker\Enums\Heroicons;
Action::make('edit')
->icon(Heroicons::OutlinedPencil)
Action::make('delete')
->icon(Heroicons::OutlinedTrash)
use Wallacemartinss\FilamentIconPicker\Enums\Heroicons;
// Get icon value
Heroicons::OutlinedStar->value; // 'heroicon-o-star'
// Get all options (useful for selects)
Heroicons::options(); // ['OutlinedStar' => 'heroicon-o-star', ...]
// Search icons
Heroicons::search('star'); // Returns matching cases
// Works with Filament's ScalableIcon interface
Heroicons::OutlinedStar->getIconForSize(IconSize::Medium);
// config/filament-icon-picker.php
return [
/*
|--------------------------------------------------------------------------
| Allowed Icon Sets
|--------------------------------------------------------------------------
|
| Define which icon sets should be available in the picker.
| Leave empty array [] to allow all installed blade-icon sets.
|
| Important: Use the exact set name, not the package name!
| Examples:
| - 'heroicons' (from blade-heroicons)
| - 'fontawesome-solid', 'fontawesome-regular', 'fontawesome-brands' (from blade-fontawesome)
| - 'phosphor-icons' (from blade-phosphor-icons)
| - 'google-material-design-icons' (from blade-google-material-design-icons)
|
*/
'allowed_sets' => [],
/*
|--------------------------------------------------------------------------
| Icons Per Page
|--------------------------------------------------------------------------
|
| Number of icons to load initially and on each scroll batch.
| Increase for faster browsing, decrease for better performance.
|
*/
'icons_per_page' => 100,
/*
|--------------------------------------------------------------------------
| Column Layout
|--------------------------------------------------------------------------
|
| Number of columns in the icon grid for different screen sizes.
|
*/
'columns' => [
'default' => 5,
'sm' => 7,
'md' => 9,
'lg' => 10,
],
/*
|--------------------------------------------------------------------------
| Modal Size
|--------------------------------------------------------------------------
|
| The size of the icon picker modal.
| Options: 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', '7xl'
|
*/
'modal_size' => '4xl',
/*
|--------------------------------------------------------------------------
| Cache Icons
|--------------------------------------------------------------------------
|
| Whether to cache the icon list for better performance.
| Set to false during development if you're adding new icons frequently.
|
*/
'cache_icons' => true,
/*
|--------------------------------------------------------------------------
| Cache Duration
|--------------------------------------------------------------------------
|
| How long to cache the icon list (in seconds).
| Default: 86400 (24 hours)
|
*/
'cache_duration' => 86400,
];
use Wallacemartinss\FilamentIconPicker\IconSetManager;
$manager = new IconSetManager();
print_r($manager->getSetNames());