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+.
Install the package:
composer require themesberg/flowbite-blade-icons
Verify installation by using an icon in a Blade view:
<x-fwb-o-adjustments-horizontal class="w-6 h-6 text-gray-500" />
This renders the "Adjustments Horizontal" outline icon with Tailwind classes.
Explore available icons:
<x-fwb-o-{icon-name}/><x-fwb-s-{icon-name}/>Replace placeholder icons in a dashboard with Flowbite icons:
<div class="flex space-x-4">
<x-fwb-o-home class="w-8 h-8 text-blue-500" />
<x-fwb-o-settings class="w-8 h-8 text-gray-500" />
<x-fwb-o-users class="w-8 h-8 text-purple-500" />
</div>
<x-fwb-o-{icon-name} />
<x-fwb-s-{icon-name} class="w-6 h-6 text-blue-600 hover:text-blue-800" />
<x-fwb-o-{icon-name} style="color: #3b82f6; width: 24px; height: 24px;" />
@svg DirectiveUseful for dynamic icon selection (e.g., based on user role):
@svg('fwb-' . ($user->isAdmin ? 's' : 'o') . '-settings', 'w-6 h-6', ['class' => 'text-gray-500'])
Publish and use SVGs directly in HTML:
php artisan vendor:publish --tag=flowbite-blade-icons --force
<img src="{{ asset('vendor/flowbite-blade-icons/o-adjustments-horizontal.svg') }}" alt="Settings" width="20" height="20" />
Publish the config file to customize defaults:
php artisan vendor:publish --tag=flowbite-blade-icons-config
Configure in config/flowbite-blade-icons.php:
'default_classes' => 'w-5 h-5',
'default_attributes' => ['fill' => 'currentColor'],
Pair icons with Flowbite buttons for consistency:
<button class="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded">
<x-fwb-o-settings />
Settings
</button>
Leverage currentColor and Tailwind’s dark: variants:
<x-fwb-o-moon class="w-6 h-6 text-gray-500 dark:text-gray-300" />
Enable caching in config/flowbite-blade-icons.php:
'cache' => true,
Then clear Blade cache after updates:
php artisan view:clear
Extend the package by publishing additional SVGs to public/vendor/flowbite-blade-icons/ and referencing them directly.
Icon Naming Confusion
fwb-o-{icon} (outline) and fwb-s-{icon} (solid) prefixes.Caching Issues
php artisan view:clear or disable caching temporarily during development:
'cache' => env('APP_ENV') !== 'local',
SVG Asset Paths
--force flag is used during publishing:
php artisan vendor:publish --tag=flowbite-blade-icons --force
Tailwind Class Conflicts
fill or stroke attributes overriding Tailwind colors.currentColor in the config or rely solely on Tailwind classes:
<x-fwb-o-settings class="w-6 h-6 text-blue-500" /> <!-- Preferred -->
Laravel Version Mismatches
composer update themesberg/flowbite-blade-icons
resources/svg directory.php artisan view:compile and check the compiled view for SVG output.{!! file_get_contents(public_path('vendor/flowbite-blade-icons/o-adjustments-horizontal.svg')) !!}
Custom Icon Directives
Extend the @svg directive in a service provider:
Blade::directive('customIcon', function ($expression) {
return "<?php echo file_get_contents(public_path('vendor/flowbite-blade-icons/{$expression}.svg')); ?>";
});
Usage:
@customIcon('o-adjustments-horizontal')
Dynamic Icon Loading For dynamic icon selection (e.g., based on API data), use a Blade component:
<x-dynamic-icon :name="$iconName" :type="$iconType" />
Component logic:
@props(['name', 'type' => 'o'])
<x-fwb-{{ $type }}-{{ $name }} />
Icon Size Utilities Create a custom Blade directive for consistent icon sizing:
Blade::directive('icon', function ($expression) {
return "<x-fwb-o-{$expression} class=\"w-5 h-5\" />";
});
Usage:
@icon('settings')
config/flowbite-blade-icons.php for production:
'cache' => env('APP_ENV') === 'production',
public folder.document.querySelectorAll('img[src*="flowbite-blade-icons"]').forEach(img => {
if (!img.src.includes('critical-icon.svg')) {
img.loading = 'lazy';
}
});
How can I help you explore Laravel packages today?