Blade Icons
Blade Icons stats
- Downloads
- 5.4M
- Stars
- 1,888
- Open Issues
- 1
- Forks
- 128
A package to easily make use of icons in your Laravel Blade views.
Blade Icons
Blade Icons is a versatile Laravel package designed to simplify the integration and management of SVG icons within Laravel Blade views. It is a refined evolution of "Blade SVG" originally developed by Adam Wathan.
Key Features
- Ease of Use: Convert verbose SVG HTML markup into clean Blade component tags or directives.
- Extensive Icon Support: Compatible with a broad range of third-party icon sets, thanks to community contributions.
- Caching: Includes a caching mechanism to enhance performance when dealing with large icon sets.
- Flexible Configuration: Supports custom icon sets, default classes, attributes, prefixes, and multi-path icons.
- Component and Directive Options: Use Blade components or directives based on preference.
- Fallback Icons: Specify fallback icons to ensure graceful handling of missing icons.
Installation
- Install via composer:
composer require blade-ui-kit/blade-icons
- Publish the configuration file:
Ensure to uncomment and verify thephp artisan vendor:publish --tag=blade-iconsdefaulticon set path in the published config, typically pointing toresources/svg.
Usage
Blade Icons can be used in various ways including:
- Blade Components, simplifying syntax to:
<x-icon-camera class="w-6 h-6"/>
- Directives, allowing for:
@svg('camera', 'w-6 h-6')
- Helper Functions, for a fluent syntax:
{{ svg('camera')->class('w-6 h-6') }}
Configuration
To customize icon sets, classes, attributes, or prefixes, modify the blade-icons.php in your config directory. You can define multiple icon sets with custom paths or even use external storage disks like AWS S3.
Caching
To cache icons for production, use:
php artisan icons:cache
This optimizes performance by creating a manifest of all icon sets and their paths.
Building Custom Icon Packages
For those interested in extending functionality with custom icons, Blade Icons offers a straightforward approach to create and register new icon packages, utilizing a template repository for ease of setup.
Requirements
- PHP 7.4 or higher
- Laravel 8.0 or higher
Maintainers
Developed and maintained by Dries Vints, with the package open for contributions from the community.
License
Blade Icons is released under the MIT license, ensuring it is free to use and modify.
This package not only simplifies the management and deployment of icons across Laravel applications but also encourages best practices with its flexible and developer-friendly API.