Installation:
composer require codeat3/blade-coolicons
Cache Icons (Critical for production):
php artisan icons:cache
Add this to your deployment pipeline (e.g., deploy.php or CI/CD script).
First Usage: Use any Coolicons icon directly in Blade:
<x-coolicon-bulb class="w-5 h-5 text-blue-500"/>
Verify the icon renders correctly by inspecting the compiled SVG in the browser.
bulb, heart).config/blade-coolicons.php) – Check if default classes/attributes need customization.Replace a legacy icon system (e.g., Font Awesome or custom SVGs) in a high-traffic component like a dashboard header or navigation bar. Example migration:
<!-- Before (Font Awesome) -->
<i class="fas fa-bell"></i>
<!-- After (Blade Coolicons) -->
<x-coolicon-bell class="w-6 h-6"/>
<x-coolicon-home/>
<x-coolicon-settings class="w-4 h-4 text-gray-400 hover:text-gray-600"/>
@auth
<x-coolicon-user class="w-5 h-5"/>
@else
<x-coolicon-login class="w-5 h-5"/>
@endauth
<x-coolicon-moon style="color: {{ request()->wantsDarkMode() ? '#9ca3af' : '#1f2937' }}"/>
php artisan vendor:publish --tag=blade-coolicons --force
<img src="{{ asset('vendor/blade-coolicons/bulb.svg') }}" alt="Bulb" width="24" height="24"/>
@foreach($menuItems as $item)
<x-coolicon-{{ $item->icon }} class="w-5 h-5 mr-2"/>
{{ $item->name }}
@endforeach
config/blade-coolicons.php set cache to false).php artisan icons:clear to reset cached icons during development.@foreach(['home', 'settings', 'logout'] as $icon)
<x-coolicon-{{ $icon }}/>
@endforeach
php artisan icons:cache
post-deploy hook (e.g., Forge/Deployer):
task('deploy:icons', function () {
run('php artisan icons:cache');
})->desc('Cache Blade Coolicons icons');
<x-coolicon-star class="w-{{ $rating }} h-{{ $rating }} text-yellow-400"/>
// tailwind.config.js
module.exports = {
plugins: [
function({ addComponents }) {
addComponents({
'.icon-default': {
'width': '1em',
'height': '1em',
'color': 'currentColor'
}
});
}
]
};
<x-coolicon-home class="icon-default text-gray-500"/>
<div x-data="{ open: false }">
<button @click="open = !open">
<x-coolicon-chevron-down class="w-4 h-4 transition-transform" :class="{ 'rotate-180': open }"/>
</button>
</div>
request()->wantsDarkMode():
<x-coolicon-moon class="text-gray-500 dark:text-gray-400"/>
Or dynamically:
<x-coolicon-moon :class="request()->wantsDarkMode() ? 'text-gray-400' : 'text-gray-500'"/>
resources/svg/ (requires rebuilding components).php artisan icons:make custom-icon --name=my-custom-icon
Then reference it in Blade:
<x-coolicon-my-custom-icon/>
Forgetting to Cache Icons in Production
php artisan icons:cache post-deploy. Add it to your deployment script.storage/framework/cache/data/blade-icons/ for cached files.Icon Names Mismatch
<x-coolicon-nonexistent/> renders nothing or throws an error.cool-icon, not CoolIcon).php artisan icons:list
Caching Issues After Icon Updates
php artisan icons:clear
php artisan icons:cache
SVG Attribute Conflicts
stroke attributes.Non-Blade Contexts
public/vendor/blade-coolicons/ directory exists and permissions are correct (chmod -R 755).| Issue | Command/Check | Solution |
|---|---|---|
| Icons not rendering | php artisan icons:list |
Verify icon name exists. |
| Slow icon load | Check storage/framework/cache/ |
Run php artisan icons:cache. |
| Styling not applying | Inspect compiled SVG in DevTools | Use !important or inline styles. |
| Cache not updating | php artisan icons:clear |
Clear and regenerate cache. |
| Class/attribute conflicts | config/blade-coolicons.php |
Override defaults in config. |
config/blade-coolicons.php:
'defaults' => [
'class' => 'w
How can I help you explore Laravel packages today?