Use Font Awesome 5 with Blade SVG

Submitted by webartisan - 5 months ago

I originally published this trick on Medium: https://medium.com/@simondepelchin/how-to-use-font-awesome-5-svgs-with-laravel-blade-a5dc93743cd0

<?php

// Install https://github.com/adamwathan/blade-svg
// composer require nothingworks/blade-svg

// Publish config
// php artisan vendor:publish --provider="BladeSvg\BladeSvgServiceProvider"

// Add 'icon' class to all svgs in `config/blade-svg.php`
/* 
return [
    //  ...
    'class' => 'icon', // Add the `icon` class to every SVG when rendered
    //  ...
];
*/
// Define the .icon class in your CSS. Here's some nice default styling.
/*
.icon {
    fill: currentColor;
    display: inline-block;
    font-size: inherit;
    height: 1em;
    overflow: visible;
    vertical-align: -.125em;
}
*/

// Use the @svg directive in your views
?>

@svg('brands/github')
@svg('regular/users', 'text-white')
comments powered by Disqus