Download the PHP package tomhatzer/blade-svg-origin without Composer
On this page you can find all versions of the php package tomhatzer/blade-svg-origin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package blade-svg-origin
This is an unmaintained fork of the original blade-svg repository by adamwathan made compatible with Laravel 8.
Blade SVG
Easily inline SVG images in your Blade templates.
Installation
You can install this package via Composer by running this command in your terminal in the root of your project:
composer require tomhatzer/blade-svg-origin
Getting started
The package's service provider will automatically register itself.
Publish the Blade SVG config file:
Configuration
Inside config/blade-svg.php, you can specify any default CSS classes you'd like to be applied to your SVG images using the class option:
You can specify multiple classes by separating them with a space, just like you would in an HTML class attribute:
Basic usage
To insert an SVG in your template, simply use the @svg Blade directive, passing the name of the SVG and optionally any additional classes:
To add additional attributes to the rendered SVG tag, pass an associative array as the third parameter:
If you have attributes to declare but no additional class, you can pass an associative array as the second parameter instead:
If you'd like to override the default class name, specify a class in the attributes array:
If you'd like to add an attribute that needs no value, just specify it without a key:
If you'd like, you can use the svg_image helper directly to expose a fluent syntax for setting SVG attributes:
Using a spritesheet
I recommend just rendering icons inline because it's really simple, has a few advantages over spritesheets, and has no real disadvantages, but if you really want to use a spritesheet, who am I to stop you?
So if you'd rather use a sprite sheet instead of rendering your SVGs inline, start by configuring the path to your spritesheet in the blade-svg config file:
If the ID attributes of the SVGs in your spritesheet have a prefix, you can configure that using the sprite_prefix option:
Next, set the inline option to false which will tell Blade SVG to render icons using the spritesheet by default instead of inlining the entire SVG:
Make sure you render the hidden sprite sheet somewhere at the end of any layouts that use SVGs by using the svg_spritesheet() helper:
You can force an SVG to reference the sprite sheet even if you are rendering inline by default by using the fluent syntax and chaining the sprite method:
Similarly, you can force an SVG to render inline even if you are using sprites by default by chaining the inline method:
All versions of blade-svg-origin with dependencies
illuminate/filesystem Version ^5.3|^6.0|^7.0|^8.0