orchid/blade-icons

An easy way inline SVG images in your Blade templates.

Fund package maintenance!
Open Collective

2.0.0 2022-02-10 09:20 UTC

This package is auto-updated.

Last update: 2022-05-13 00:11:25 UTC


README

badge.svg Packagist Packagist Version

Introduction

This is a package for the Laravel framework that allows you to use the Blade component to insert inline SVG images.

Installation

Run this at the command line:

$ composer require orchid/blade-icons

This will update composer.json and install the package into the vendor/ directory.

Base Usage

Register a directory with your files in the service provider:

namespace App\Providers;

use Orchid\Icons\IconFinder;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(IconFinder $iconFinder) : void
    {
        $iconFinder->registerIconDirectory('fa', storage_path('app/fontawesome'));
    }
}

When calling the directory method with the first argument, we pass the prefix to call our icons and the second directory where they are located.

After that, we can call the component in our blade templates:

<x-orchid-icon path="fa.home" />

If you use one or two sets of icons that do not repeat, then it is not necessary to specify a prefix in the component:

<x-orchid-icon path="home" />

You can also list some attributes that should be applied to your icon:

<x-orchid-icon 
    path="home" 
    class="icon-big" 
    width="2em" 
    height="2em" />

License

The MIT License (MIT). Please see License File for more information.