This module adds a simple method to include inline SVGs in twig templates.
To configure:
1. Ensure your combined SVG file is in your default theme /images/ folder - I'd recommend using Gulp to do this. @see
https://www.npmjs.com/package/gulp-cheerio
https://www.npmjs.com/package/gulp-svgstore
https://www.npmjs.com/package/gulp-svgstore#transform-svg-sources-or-com...
2. Optionally, configure svg file paths via /admin/config/twig_svg/config
3. Enable the Twig SVG module
4. To include an SVG icon in a twig template, add the following in the relevant
html.twig file:
{{ icon('icon-name', 'Icon title') }}
Optionally, to add a title, classes, and additional attributes:
{{ icon('icon-name', 'Icon title', ['extra-class', 'another-class'], {'name-one': 'value-one', 'name-two': 'value-two'}) }}
Optionally, to add a title, classes, additional attributes and wrapper classes:
{{ icon('icon-name', 'Icon title', ['extra-class', 'another-class'], {'name-one': 'value-one', 'name-two': 'value-two'}, ['wrapper-class-1', 'wrapper-class-2']) }}
Credit to https://www.lullabot.com/articles/better-svg-sprite-reuse-in-drupal-8 for the fundamentals of this.
Project information
157 sites report using this module
- Created by aaron.ferris on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 2.0.x-dev updated 13 Sep 2024 at 17:39 UTC
Development version: 8.x-1.x-dev updated 13 Sep 2024 at 17:42 UTC

