themesberg/flowbite-blade-icons
Use Flowbite Icons in Laravel Blade via Blade UI Kit. Provides outline and solid SVG icons as Blade components and @svg directive, with support for classes, attributes, and caching. PHP 8.1+ and Laravel 9+.
composer require themesberg/flowbite-blade-icons in your Laravel project (PHP 8.1+, Laravel 9+).<x-fwb-o-adjustments-horizontal class="w-5 h-5 text-gray-800" />
resources/svg directory in the package.w-5 h-5) and currentColor inheritance.<x-fwb-{type}-{icon-name}/> for outline (o-) or solid (s-) icons:
<x-fwb-o-home class="text-blue-500 hover:text-blue-700" />
@php
$icon = config('app.dashboard_icon', 'fwb-o-dashboard');
@endphp
<x-fwb-{{ $icon }} class="w-6 h-6" />
@auth
<x-fwb-o-user />
@else
<x-fwb-o-login />
@endauth
@svg Directive@svg('fwb-o-{icon}', 'classes', ['attrs']) for dynamic or reusable icons:
@svg('fwb-o-settings', 'w-5 h-5', ['aria-label' => 'Settings'])
@component('svg-icon', ['icon' => 'fwb-o-notification', 'classes' => 'w-6 h-6'])
@slot('default')
{{ __('New notifications') }}
@endslot
@endcomponent
php artisan vendor:publish --tag=flowbite-blade-icons-config
// config/flowbite-blade-icons.php
'default_classes' => 'w-5 h-5 text-gray-500',
'default_attributes' => ['aria-hidden' => 'true'],
// AppServiceProvider
BladeIcons::defaultClasses('w-4 h-4');
<img> tags):
php artisan vendor:publish --tag=flowbite-blade-icons --force
<img src="{{ asset('vendor/flowbite-blade-icons/o-home.svg') }}" alt="Home" class="w-6 h-6" />
<button class="flex items-center gap-2 bg-blue-500 text-white px-4 py-2 rounded">
<x-fwb-o-settings />
Settings
</button>
<div x-data="{ open: false }" class="relative">
<button @click="open = !open" class="flex items-center gap-1">
<x-fwb-o-chevron-down />
</button>
<!-- Dropdown content -->
</div>
php artisan vendor:publish --tag=blade-icons-config
// config/blade-icons.php
'cache' => true,
'cache_path' => storage_path('framework/cache/blade-icons'),
Icon Naming Conflicts:
fwb-o-home vs. fwb-s-home).o-/s-) or alias components in a service provider:
Blade::component('home-icon', \Themesberg\FlowbiteBladeIcons\Components\Outline\Home::class);
<x-home-icon />
Tailwind Class Conflicts:
currentColor may override Tailwind’s text-{color} classes if not scoped properly.text-{color} after the icon component:
<x-fwb-o-settings class="w-5 h-5" style="color: inherit" /> <span class="text-blue-500">Settings</span>
Or wrap in a div with Tailwind classes:
<div class="text-blue-500">
<x-fwb-o-settings class="w-5 h-5" />
</div>
Caching Quirks:
php artisan view:clear
php artisan cache:clear
'cache' => env('APP_DEBUG')).SVG Attribute Injection:
@svg directive for complex attributes:
@svg('fwb-o-alert', 'w-5 h-5', [
'aria-label' => 'Alert',
'data-testid' => 'alert-icon',
])
Laravel Mix/Webpack Conflicts:
vendor/flowbite-blade-icons directory from Mix processing in webpack.mix.js:
mix.excludeChunks(['vendor/flowbite-blade-icons']);
Inspect Compiled Blade:
{{ \Themesberg\FlowbiteBladeIcons\Components\Outline\Home::render() }}
storage/framework/views.Icon Existence:
resources/svg directory or Flowbite Icons.dd(\Themesberg\FlowbiteBladeIcons\Icons::all()) to list available icons.Class/Attribute Precedence:
config/flowbite-blade-icons.php) → Component attributes → Inline styles.!important in CSS if needed:
.fwb-icon !important {
color: inherit !important;
}
Custom Icons:
// app/Providers/AppServiceProvider.php
use Themesberg\FlowbiteBladeIcons\BladeIcons;
public function boot()
{
BladeIcons::add('fwb-c-custom', file_get_contents(resource_path('svg/custom.svg')));
}
<x-fwb-c-custom class="w-6 h-6" />
Dynamic Icon Loading:
// app/Providers/AppServiceProvider.php
BladeIcons::macro('dynamic', function ($iconName, $svgContent) {
BladeIcons::add("fwb-d-$iconName", $svgContent);
});
@php
$customSvg = '<svg>...</svg>';
\Themesberg\FlowbiteBladeIcons\BladeIcons::dynamic('user', $customSvg);
@endphp
<x-fwb-d-user />
Icon Sets:
BladeIcons::load(__DIR__.'/../../vendor/heroicons/blade-icons/src');
Dark Mode Optimization:
currentColor forHow can I help you explore Laravel packages today?