collapsible-resource-manager
collapsible-resource-manager copied to clipboard
Recipe: Font Awesome icons
-
composer require nothingworks/blade-svg
-
php artisan vendor:publish --provider="BladeSvg\BladeSvgServiceProvider"
- download and configure the path to Fontawesome SVG as described on https://medium.com/@simondepelchin/how-to-use-font-awesome-5-svgs-with-laravel-blade-a5dc93743cd0
- make a helper function
function faIcon($faIcon, $group = 'solid')
{
try {
return svg_image($group . '/' . $faIcon, '', ['width' => '24px', 'height' => '24px', 'fill' => 'var(--sidebar-icon)'])->toHtml();
} catch (FileNotFoundException $exception) {
return svg_image( 'regular/question-circle' , '', ['width' => '24px', 'height' => '24px', 'fill' => 'var(--sidebar-icon)'])->toHtml();
}
}
and you are ready to add icons like this:
->icon(faIcon('language'))
or
'icon' => faIcon('users-cog'),
Hey @cord, thank you for the solution! Works like a charm ;)
Just a quick note, due to the deprecation of the BladeSvg package and the transition to BladeUI/Icons, a couple of things change a bit.
Now to publish the package, use php artisan vendor:publish --tag=blade-ui-kit-config
And instead of the svg_image
function in the helper, use svg
;)
Have a good day!
This still works with the latest version, I kept a way to manually specify icons SVG since nova ships only with heroicons v1 ...