collapsible-resource-manager icon indicating copy to clipboard operation
collapsible-resource-manager copied to clipboard

Recipe: Font Awesome icons

Open cord opened this issue 4 years ago • 1 comments

  1. composer require nothingworks/blade-svg
  2. php artisan vendor:publish --provider="BladeSvg\BladeSvgServiceProvider"
  3. 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
  4. 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'),

cord avatar May 29 '20 12:05 cord

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!

dragomirt avatar Mar 11 '21 11:03 dragomirt

This still works with the latest version, I kept a way to manually specify icons SVG since nova ships only with heroicons v1 ...

milewski avatar Oct 07 '23 06:10 milewski