daljo25/blade-pixelicon-icons
Laravel Blade UI Kit icon set for the Pixel Icon Library by HackerNoon. Includes 450+ SVG icons (regular, solid, brands, purcats) with Blade components, @svg directive, and svg() helper. Auto-injects fill="currentColor" for easy CSS color control.
Installation
composer require daljo25/blade-pixelicon-icons
Publish the config (if needed):
php artisan vendor:publish --provider="Daljo25\BladePixeliconIcons\BladePixeliconIconsServiceProvider"
First Use Case Add the directive to your Blade view:
@pixelicon('icon-name', ['class' => 'text-blue-500'])
Example output:
@pixelicon('home', ['class' => 'w-6 h-6'])
Where to Look First
config/blade-pixelicon-icons.php (default paths, icon sets).app/Providers/BladePixeliconIconsServiceProvider.php for registered directives.Basic Icon Usage
@pixelicon('user', ['class' => 'text-gray-600'])
Dynamic Icons with Variables
@pixelicon($dynamicIconName, ['class' => 'w-5 h-5'])
{{ $user->role === 'admin' ? 'admin' : 'user' }}).Customizing Icons
@pixelicon('settings', ['class' => 'fill-current', 'width' => '24', 'height' => '24'])
<div class="p-2">
@pixelicon('search', ['class' => 'text-gray-400'])
</div>
Integration with Tailwind CSS
@pixelicon('bell', ['class' => 'w-6 h-6 text-indigo-500 hover:text-indigo-700'])
Reusable Components Create a Blade component for consistent icon usage:
@component('components.icon', ['name' => 'edit', 'classes' => 'text-green-500'])
@endcomponent
<!-- resources/views/components/icon.blade.php -->
@pixelicon($name, ['class' => $classes])
Icon Sets If the package supports multiple icon sets (e.g., solid, outline), specify the set:
@pixelicon('set:outline|home', ['class' => 'w-6 h-6'])
Icon Not Found
home vs. home-alt).user-profile).Caching Issues
php artisan view:clear
SVG Rendering Quirks
viewBox or fill attributes.@pixelicon('star', ['fill' => 'currentColor', 'viewBox' => '0 0 24 24'])
Path Configuration
icon_path in the config is incorrect.public/icons/pixel-icons).Inspect the Generated SVG Use browser dev tools to check if the SVG is rendered correctly. Look for:
xlink:href pointing to a 404).Log Icon Resolution Temporarily add logging to the directive to debug icon resolution:
// In BladePixeliconIconsServiceProvider.php
Blade::directive('pixelicon', function ($expression) {
$iconName = eval("return {$expression};");
\Log::debug("Resolving icon: {$iconName}");
// ... rest of the directive logic
});
Fallback for Missing Icons Provide a fallback SVG or text if an icon fails to load:
@pixelicon($iconName ?? 'unknown', [
'class' => 'text-gray-400',
'fallback' => '?'
])
(Note: Implement this in the package’s directive logic if not supported out-of-the-box.)
Custom Icon Sets Extend the package to support additional icon sets by:
icon_paths.resolveIconPath method in the service provider.Dynamic Styling Add a filter for dynamic styling (e.g., based on user preferences):
@pixelicon('theme:dark|moon', ['class' => 'text-white'])
(Requires custom logic in the directive.)
Animation Support Animate icons using CSS or JavaScript by wrapping them:
<div class="animate-pulse">
@pixelicon('loading', ['class' => 'w-5 h-5'])
</div>
Localization
Support localized icon names (e.g., home → inicio for Spanish) by:
Inline Critical Icons For above-the-fold icons, inline the SVG directly in the Blade view to avoid extra HTTP requests:
{!! file_get_contents(public_path('icons/pixel-icons/home.svg')) !!}
(Use sparingly to avoid bloating your templates.)
Sprite Sheets
Combine all icons into a sprite sheet and use CSS background-image for better performance:
.icon-home { background-image: url('/icons/pixel-icons-sprite.svg#home'); }
(Requires preprocessing the icons into a sprite sheet.)
Lazy Loading
Defer non-critical icons using loading="lazy" on a parent container:
<div loading="lazy">
@pixelicon('non-critical-icon')
</div>
How can I help you explore Laravel packages today?