wireui/heroicons
Laravel package that brings Heroicons to WireUI, providing ready-to-use SVG icon components you can drop into your Blade views and WireUI components for consistent, customizable icons across your app.
composer require wireui/heroicons
npm install @heroicons/tailwind # If not already installed
tailwind.config.js:
plugins: [
require('wireui/tailwind'),
],
@heroicon directive in Blade templates:
@heroicon('solid/check-circle', class="h-6 w-6 text-green-500")
solid/check-circle).outline/shopping-cart).mini/star).@heroicon syntax and available variants.Replace a manually added SVG icon in a Blade component (e.g., a button) with @heroicon:
<!-- Before -->
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
Save
</button>
<!-- After -->
<button>
@heroicon('solid/arrow-up-right', class="h-6 w-6")
Save
</button>
Consistent Icon Sizing:
Use Tailwind’s utility classes for sizing (e.g., h-4 w-4, h-6 w-6, h-8 w-8).
@heroicon('solid/bell', class="h-5 w-5")
Dynamic Icons with Blade Logic: Pass dynamic classes or icon names based on conditions:
@heroicon(
$isActive ? 'solid/check-circle' : 'outline/x-circle',
class="h-6 w-6 text-" . ($isActive ? 'green-500' : 'red-500')
)
Component Integration: Create reusable Blade components for common icon patterns:
@component('components.icon', [
'name' => 'solid/arrow-left',
'size' => 'h-6 w-6',
'color' => 'text-gray-500',
])
@endcomponent
Dark Mode Support: Leverage Tailwind’s dark mode classes:
@heroicon('solid/moon', class="h-6 w-6 dark:text-gray-500")
Micro Interactions: Combine with Alpine.js for hover/focus effects:
<div x-data="{ hover: false }" @mouseover="hover = true" @mouseleave="hover = false">
@heroicon(
$hover ? 'solid/star' : 'outline/star',
class="h-6 w-6 transition-colors duration-200"
)
</div>
Design System Alignment:
tailwind.config.js (e.g., prefix all custom icons with custom/).// tailwind.config.js
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
// Custom icon prefixes
icon: {
prefix: 'custom/',
},
},
},
Icon Inventory Management:
README.md or spreadsheet listing all used icons (e.g., solid/user, outline/cog).| Icon Name | Usage Context | Component |
|-----------------|-------------------------|--------------------|
| solid/check | Success messages | Alert Component |
| outline/plus | Add buttons | Form Actions |
Theming:
// tailwind.config.js
theme: {
extend: {
colors: {
'icon-primary': '#3b82f6',
'icon-secondary': '#10b981',
},
},
},
@heroicon('solid/star', class="h-6 w-6 text-icon-primary")
Livewire/Inertia Integration:
// Livewire Component
public $iconName = 'solid/check-circle';
<!-- Blade View -->
@heroicon($iconName, class="h-6 w-6")
Accessibility:
aria-hidden and focusable="false" for decorative icons:
@heroicon('solid/info-circle', class="h-5 w-5 text-blue-500", aria-hidden="true", focusable="false")
aria-label for actionable icons:
<button aria-label="Notifications">
@heroicon('solid/bell', class="h-6 w-6")
</button>
Laravel Mix/Vite:
Ensure Heroicons are processed during builds. If using Vite, add this to vite.config.js:
optimizeDeps: {
include: ['@heroicons/tailwind'],
},
PurgeCSS: If using Tailwind’s JIT mode or PurgeCSS, ensure Heroicons are not purged:
// tailwind.config.js
purge: {
content: [
'./resources/**/*.blade.php',
'./resources/**/*.js',
'./resources/**/*.vue',
],
// Add Heroicons to safelist
safelist: [
/^heroicon-/,
/^h-\d+$/,
/^w-\d+$/,
/^text-.*$/,
],
},
Testing:
npm run dev -- --mode dark
Performance:
h-4 w-4 (mini variants) for non-critical icons to reduce file size.Custom Icons:
@apply:
<svg class="h-6 w-6 @apply fill-current text-blue-500" ...>
<!-- Custom SVG path -->
</svg>
Blade Cache Issues:
php artisan view:clear
composer.json scripts for future updates:
"post-update-cmd": [
"@php artisan view:clear"
]
Tailwind Version Mismatches:
composer.json:
"require": {
"tailwindcss": "^3.0"
}
Missing Icons:
solid/check-cirle instead of solid/check-circle) will render nothing.CSS Conflicts:
fill-current or stroke-current can break icons.!important sparingly or inspect the SVG with browser dev tools.Build Step Failures:
@heroicons/tailwind is included in dependencies.Module not found: Error: Can't resolve '@heroicons/tailwind'.npm install @heroicons/tailwind and rebuild assets.Dark Mode Quirks:
How can I help you explore Laravel packages today?