postare/blade-mdi
Laravel package providing Material Design Icons as Blade UI Kit components. Includes updated dependencies, new icons, and SVGs set to fill="currentColor" for Tailwind CSS. Use icons like and optionally publish SVGs locally.
Installation:
composer require postare/blade-mdi
No additional configuration is required for basic usage.
First Use Case: Use the package in a Blade view by referencing an icon directly:
<x-mdi-account /> <!-- Renders the account icon -->
Or via the helper syntax (if available):
@mdi('account')
Where to Look First:
Blade Component Syntax (Recommended):
Use the <x-mdi-* /> syntax for type safety and autocompletion:
<x-mdi-home />
<x-mdi-settings />
Dynamic Icons via Variables: Pass dynamic icon names using Blade variables:
@php
$iconName = 'account';
@endphp
<x-mdi-{{ $iconName }} />
Tailwind CSS Integration:
Leverage the fill-current property for dynamic theming:
<x-mdi-alert class="text-red-500" />
Icon Groups in Layouts:
Centralize icon usage in a layout file (e.g., resources/views/layouts/app.blade.php):
<div class="icon-group">
<x-mdi-home class="icon" />
<x-mdi-settings class="icon" />
</div>
Livewire Component Icons: Use icons in Livewire components for interactive elements:
<x-mdi-delete wire:click="deleteItem" class="cursor-pointer" />
Icon Discovery Workflow:
Theming Workflow:
<x-mdi-star class="text-yellow-400 hover:text-yellow-500" />
.icon-primary { color: var(--primary-color); }
Asset Optimization Workflow:
php artisan vendor:publish --provider="Postare\BladeMdi\BladeMdiServiceProvider" --tag="blade-mdi"
svgo or laravel-mix-svgo.Testing Workflow:
public function test_icon_renders()
{
$this->blade()->render('<x-mdi-home />')
->assertSee('<svg');
}
Laravel Mix/Vite Integration:
vite.config.js:
export default defineConfig({
assets: {
include: ['resources/svg/**/*'],
},
});
Livewire Integration:
<button wire:click="save">
<x-mdi-content-save class="mr-2" />
Save
</button>
Dark Mode Support:
<x-mdi-moon class="dark:text-gray-300" />
Custom Icon Aliases:
'aliases' => [
'home' => 'mdi-home',
],
Fallback for Missing Icons:
@isset($iconName)
<x-mdi-{{ $iconName }} />
@else
<x-mdi-alert class="text-gray-400" />
@endisset
Icon Name Mismatches:
mdi-account vs. account). Use the Blade UI Kit to verify names.SVG Asset Loading:
php artisan vendor:publish --tag="blade-mdi"
Tailwind Conflicts:
fill-current property may conflict with Tailwind’s fill-* utilities. Use !important or custom CSS if needed:
<x-mdi-star style="--tw-fill-opacity: 1;" class="text-yellow-500" />
Laravel 12 Compatibility:
@props). Report issues to the GitHub repo.Caching Issues:
php artisan view:clear
php artisan cache:clear
npm run dev
Missing Icons:
Blade Syntax Errors:
php artisan blade:compile to debug:
php artisan blade:compile --debug
SVG Rendering Issues:
fill or stroke properties.Performance Bottlenecks:
webpack-bundle-analyzer to check if SVGs are bloating your bundle:
npm run build -- --analyze
Autocomplete Support:
Icon Search Shortcut:
Dynamic Sizing:
w-* and h-* classes for consistent icon sizing:
<x-mdi-star class="w-6 h-6" />
Accessibility:
<x-mdi-alert aria-label="Warning" />
Customization:
<x-mdi-home class="custom-icon" style="--icon-size: 24px" />
Contributing New Icons:
download.sh to add it:
git clone https://github.com/postare/blade-mdi.git
cd blade-mdi
./download.sh
Testing New Icons:
blade testing helpers:
$this->blade()->render('<x-mdi-new-icon />')->assertSeeText('new-icon');
Laravel Mix Optimization:
mix.setPublicPath('public')
.svg('resources/svg/icons', 'public/svg', (path) => {
return path.replace(/^resources\/svg/, '');
});
How can I help you explore Laravel packages today?