mallardduck/blade-lucide-icons
Laravel Blade package for Lucide icons. Provides easy-to-use Blade components to render Lucide SVGs in your views, with simple naming and props for size, stroke, and other attributes. Great for quickly adding consistent, customizable icons.
Install via Composer:
composer require mallardduck/blade-lucide-icons --update
First Use Case: Replace a generic icon in your Blade view with the latest Lucide icons (now v1.23.0):
<!-- Before -->
<i class="fa fa-user"></i>
<!-- After (using new icons) -->
<x-lucide-user />
<!-- Or try one of the 7 new icons, e.g., -->
<x-lucide-activity />
Key Starting Points:
lucide-user → <x-lucide-user />).php artisan vendor:publish --provider="BladeUI\Icons\BladeIconsServiceProvider" --tag="blade-icons-config"
Then configure cache: true in config/blade-icons.php.Pattern: Use Lucide icons (now v1.23.0) as Blade components with dynamic attributes:
<!-- Basic usage -->
<x-lucide-home class="text-blue-500 w-6 h-6" />
<!-- Using new icons (v1.23.0) -->
<x-lucide-activity class="text-purple-500 w-5 h-5" />
Workflow:
lucide.dev to find the perfect icon, including the 7 new additions (e.g., lucide-activity → <x-lucide-activity />).text-gray-400 hover:text-gray-600).w-* h-* classes (e.g., w-5 h-5 for compact icons).Pattern: Create custom Blade components to encapsulate icons with logic:
<!-- resources/views/components/StatusIcon.blade.php -->
<x-lucide-{{ $status === 'active' ? 'check-circle' : 'x-circle' }}
class="text-{{ $status === 'active' ? 'green-500' : 'red-500' }} w-4 h-4" />
Use Case: Standardize icons across your app (e.g., status indicators, buttons). Leverage the new icons from v1.23.0 for fresh designs, such as <x-lucide-activity /> for activity-related features.
Pattern: Publish and use SVG assets for non-Blade contexts (e.g., JavaScript, CSS):
php artisan vendor:publish --tag=blade-lucide-icons --force
<!-- In a non-Blade template (e.g., email) -->
<img src="{{ asset('vendor/blade-lucide-icons/activity.svg') }}" alt="Activity" width="24" height="24" />
Tip: Useful for emails, PDFs, or when Blade components aren’t available. Ensure you’re using the updated SVGs from v1.23.0, including the new icons like activity.svg.
Pattern: Publish the config file to set defaults:
php artisan vendor:publish --tag=blade-lucide-icons-config
// config/blade-lucide-icons.php
return [
'default_class' => 'w-5 h-5 text-gray-500',
'cache' => env('ICON_CACHE_ENABLED', true),
];
Result: All icons inherit w-5 h-5 text-gray-500 unless overridden. Ensure your config aligns with the latest package version (1.26.27).
Pattern: Load icons dynamically based on data (e.g., from a database):
@foreach($items as $item)
<x-lucide-{{ $item->icon }} class="w-4 h-4 mr-2" />
{{ $item->name }}
@endforeach
Tip: Store icon names as strings in your database (e.g., "user", "activity"). Verify new icons from v1.23.0 are supported.
Caching Issues:
php artisan config:clear and regenerate Blade views:
php artisan view:clear && php artisan config:clear
Icon Name Mismatches:
<x-lucide-userr /> → 404 error) or using deprecated names.SVG Asset Paths:
../vendor/...).asset('vendor/blade-lucide-icons/...') for portability. Ensure paths reflect the updated SVGs in v1.23.0, including the new icons like activity.svg.Laravel Mix/Webpack:
php artisan vendor:publish --tag=blade-lucide-icons --force
Missing Icons:
<svg> tags. If missing, the icon name is incorrect or the SVG is not published.Styling Not Applying:
text-red-500) are loaded in your CSS.<x-lucide-alert style="color: red;" />
Performance:
'cache' => true in config.php artisan cache:clear
Custom Icons:
resources/svg and extend the package by creating a custom service provider:
// app/Providers/LucideIconsServiceProvider.php
use BladeUI\Icons\BladeIconsServiceProvider;
class LucideIconsServiceProvider extends BladeIconsServiceProvider {
protected function iconsPath() {
return resource_path('svg');
}
}
config/app.php. Ensure compatibility with v1.26.27.Icon Aliases:
config/blade-lucide-icons.php:
'aliases' => [
'old-name' => 'new-name',
],
Dark Mode:
<x-lucide-moon class="dark:text-yellow-300" />
Accessibility:
aria-hidden="true" or role="img" for non-interactive icons:
<x-lucide-search aria-hidden="true" />
New Icons in v1.23.0:
<x-lucide-activity />, <x-lucide-new-icon />) and integrate them into your workflow. Check the Lucide changelog for details.<x-lucide-activity /> for activity feeds or dashboards.Modified Icons in v1.23.0:
How can I help you explore Laravel packages today?