Hey,
First of all, I create a sprite image of the icons and store this in a folder.. One folder per Icons package. And after this i create a component. On this way Im able to select multiple icon packages.
View/Components/Icons.php
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Icons extends Component
{
public $package;
public $icon;
// public $folders;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($icon, $package)
{
$this->package = '/icons/'.$package.'/';
$this->icon = $icon;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.icons');
}
}
Blade-Component "icons"
<span {{ $attributes->merge(['class' => 'fill-none mr-4 h-6 w-6']) }} >
<svg viewBox="0 0 24 24" stroke=""
stroke-width="{{ $strokeWidth ?? 1 }}"
{{ $attributes->merge(['class' => 'inline-block relative']) }}>
{{-- class="inline-block relative {{ $class ?? '' }}">--}}
<use xlink:href="{{$package}}sprite.svg#{{$icon}}" />
</svg>
</span>
Blade:
<x-icons package="{{$search->package}}" icon="{{$search->icon_name}}"
class="stroke-rose-600 w-10 h-10 ml-3 mr-3 "></x-icons>