blade-ui-kit/blade-zondicons
Use Zondicons in Laravel Blade via simple SVG components powered by Blade Icons. Install with Composer, render icons like , and customize with classes/styles or config defaults. Optionally publish raw SVG assets and enable caching.
Installation:
composer require blade-ui-kit/blade-zondicons
This installs the package and its dependency (blade-ui-kit/blade-icons).
First Use Case: Render a Zondicon directly in a Blade view:
<x-zondicon-cloud class="w-5 h-5 text-blue-500" />
Replace cloud with any Zondicon name.
Verify: Check the rendered HTML in your browser’s inspector to confirm the SVG appears with applied classes.
cloud.svg, cog.svg) to identify names for Blade components.Basic Icon Rendering:
<!-- Static icon with Tailwind classes -->
<x-zondicon-home class="w-6 h-6" />
<!-- Dynamic icon (e.g., in a loop) -->
@foreach($icons as $icon)
<x-zondicon-{{ $icon }} class="w-4 h-4" />
@endforeach
Customization via Attributes:
<!-- Inline styles -->
<x-zondicon-search style="color: #6b7280; width: 20px; height: 20px;" />
<!-- Data attributes for JS interactivity -->
<x-zondicon-bell data-tooltip="Notifications" class="w-5 h-5" />
Global Configuration (Publish Config):
php artisan vendor:publish --tag=blade-zondicons-config
Configure defaults in config/blade-zondicons.php:
'default_classes' => 'w-5 h-5 text-gray-500',
'default_attributes' => ['aria-hidden' => 'true'],
Now all icons inherit these unless overridden:
<x-zondicon-cloud /> <!-- Uses defaults -->
<x-zondicon-cloud class="text-red-500" /> <!-- Overrides color -->
Raw SVG Assets (Publish Assets):
php artisan vendor:publish --tag=blade-zondicons --force
Use SVGs directly in views or assets:
<img src="{{ asset('vendor/blade-zondicons/cloud.svg') }}" alt="Cloud" width="24" height="24" />
<x-zondicon-settings class="w-[1.25rem] h-[1.25rem]" />
<x-zondicon-moon class="dark:text-yellow-300" />
php artisan config:cache
php artisan view:cache
<x-zondicon-x
class="w-5 h-5 {{ $isActive ? 'text-green-500' : 'text-gray-400' }}"
wire:click="toggleActive"
/>
Icon Naming Conflicts:
zondicon-cloud), but Blade components omit the prefix.x-zondicon- prefix in Blade (e.g., <x-zondicon-cloud/>), not <zondicon-cloud/>.resources/views/vendor/blade-zondicons for compiled components if icons fail to render.Caching Issues:
php artisan view:clear
php artisan config:clear
SVG Asset Paths:
public/vendor/blade-zondicons/.--force flag during publish may overwrite existing files.asset('vendor/blade-zondicons/...') in Blade, not relative paths.Laravel Version Mismatches:
composer.json aligns:
"require": {
"laravel/framework": "^11.0 || ^12.0"
}
Missing Icons:
resources/svg.php artisan view:clear if icons disappear after updates.Styling Not Applying:
Custom Icons:
resources/svg and register them in config/blade-zondicons.php:
'icons' => [
'custom-icon' => 'path/to/custom.svg',
],
<x-zondicon-custom-icon />.Dynamic Icon Selection:
@component('zondicon-'.$iconName, ['class' => 'w-5 h-5'])
@endcomponent
Icon Sets:
blade-heroicons) for hybrid icon systems:
@if($useZondicon)
<x-zondicon-home />
@else
<x-heroicon-home />
@endif
php artisan blade-icons:cache
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const icon = entry.target;
icon.innerHTML = icon.dataset.icon;
observer.unobserve(icon);
}
});
});
document.querySelectorAll('[data-icon]').forEach(el => observer.observe(el));
}
<span data-icon="<x-zondicon-cloud class='w-5 h-5' />"></span>
Default Attributes:
The default_attributes config key accepts an array of attributes to apply to all icons:
'default_attributes' => [
'aria-hidden' => 'true',
'focusable' => 'false',
],
Note: Inline styles or classes override these.
Icon Size Limits: Zondicons are designed for small-to-medium sizes (typically <50px). For larger icons, consider scaling via CSS transforms:
<x-zondicon-rocket class="scale-150" />
How can I help you explore Laravel packages today?