tonegabes/filament-phosphor-icons
Installation:
composer require tonegabes/filament-phosphor-icons
Publish assets if needed (though this package is icon-only, no assets to publish).
First Use Case:
Replace default Filament icons (e.g., heroicon-o-*) with Phosphor icons in a single line:
use ToneGabes\Filament\Icons\Enums\Phosphor;
Action::make('edit')
->icon(Phosphor::Pencil); // Replaces `heroicon-o-pencil`
Where to Look First:
Phosphor enum autocompletion in your IDE (all 4,000+ icons are available).Replacing Default Icons:
// Before (Filament default)
->icon('heroicon-o-check')
// After (Phosphor)
->icon(Phosphor::Check)
Dynamic Icon Selection: Use enums in conditional logic (e.g., toggle states, status badges):
$icon = $record->is_active ? Phosphor::CheckCircle : Phosphor::XCircle;
Badge::make()->icon($icon);
Consistent Styling:
Pair with Weight enum for visual hierarchy:
Button::make()
->icon(Phosphor::GearBold)
->iconWeight(Weight::Bold); // Forces bold style
Bulk Replacement: Create a helper trait to standardize icon usage:
trait UsesPhosphorIcons {
protected function phosphor(string $name): string {
return Phosphor::from($name)->value;
}
}
Custom Icon Sets: Extend the enum for project-specific icons:
enum CustomPhosphor extends Phosphor {
case ProjectLogo = 'your-custom-icon';
}
--filament-icon-color).Case Sensitivity:
Phosphor icons are case-sensitive in the enum (e.g., Phosphor::Star ≠ Phosphor::star).
Fix: Use IDE autocompletion or check the Phosphor API.
Missing Icons: Not all Phosphor icons are included by default. Verify availability via:
dd(Phosphor::cases()); // List all loaded icons
Fix: Ensure the package is up-to-date (composer update).
Weight Overrides:
Forcing weights (e.g., Weight::Fill) may clash with Filament’s default styling.
Fix: Inspect rendered HTML/CSS to adjust --filament-icon-weight variables.
Caching: Laravel’s opcache may cache enum values. Clear cache if icons appear broken:
php artisan optimize:clear
Icon Not Rendering? Check the browser’s Network tab for failed icon requests (unlikely, but verify the package’s CDN/asset path).
IDE Autocomplete Fails: Trigger PHPStan or Psalm to generate enum stubs:
vendor/bin/phpstan analyse --generate-mock-files
Custom Icon Sets:
Override the enum in config/filament-phosphor-icons.php:
'custom_icons' => [
'ProjectLogo' => 'your-icon-name',
],
Dynamic Icon Resolution: Create a macro for runtime icon resolution:
Phosphor::macro('resolve', function (string $name) {
return Phosphor::tryFrom($name) ?? Phosphor::Question;
});
Filament Plugin Integration: Bundle with a custom Filament plugin for team-wide adoption:
Filament::registerPlugin(
Plugin::make()
->id('phosphor-icons')
->registerIcons(Phosphor::class)
);
Icon Naming Conventions:
Use *Fill for "active" states (e.g., Phosphor::CheckCircleFill).
Use *Thin for subtle UI elements (e.g., Phosphor::ChevronDownThin).
Accessibility:
Pair icons with aria-label for screen readers:
Button::make()
->icon(Phosphor::Bell)
->ariaLabel('Notifications');
Dark Mode: Phosphor icons automatically adapt to dark mode via CSS variables. No extra config needed.
How can I help you explore Laravel packages today?