phaza / laravel-blade-inline-svg
Allows you to inline svgs in html so you can use normal CSS to apply styles to your svg. (No more multiple versions of same icon with just different colour)
Installs: 66 983
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 6
Open Issues: 1
Requires
- illuminate/config: ^5.1
- illuminate/view: ^5.1
Requires (Dev)
- mockery/mockery: ^0.9.4
- orchestra/testbench: ~3.0
- phpunit/phpunit: ^5.1
This package is auto-updated.
Last update: 2024-11-13 20:51:57 UTC
README
The what
This simple extension allows you inline svgs in your templates, which means your svg turns into first class citizens of your html and can be styled with css like all other html elements. This reduces the needs for making multiple colored versions of the same icon just to add a :hover effect for instance.
a:hover svg line { fill: #r00; }
The How`
Add Phaza\InlineSvg\BladeInlineSvgServiceProvider::class
to the providers
array and
"SvgInliner" => Phaza\InlineSvg\Facades\SvgInliner::class
to the aliases
array in config/app.php
.
Optionally publish the config, it'll be named blade-inline-svg.php
.
Configuration
svg-path:
This is the default folder where the inliner should look for svg files.
Synopsis
@svg($path, $attributes)
$path
:
If $path
starts with DIRECTORY_SEPARATOR
, it's parsed as an absolute path.
If not, it's parsed as relative path starting at config('blade-inline-svg.svg-path')
$attributes
:
$attributes
is an associative array of attributes you want to set on the svg element. Use this to add classes (or transforms) to easy reference the svg.