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.
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Twig ecosystem
Most installed first
Activity
Release Timeline
Releases
| Version | Type | Core | Release date | |
|---|---|---|---|---|
| 8.x-1.10 | Stable | 8–10 | Sep 13, 2024 | |
| 2.0.0-alpha2 | Pre-release | 10–11 | Sep 13, 2024 | |
| 8.x-1.9 | Stable | Aug 16, 2024 | ||
| 8.x-1.8 | Stable | Aug 16, 2024 | ||
| 8.x-1.7 | Stable | Aug 16, 2024 | ||
| 8.x-1.6 | Stable | Aug 16, 2024 | ||
| 2.0.x-dev | Dev | Aug 16, 2024 | ||
| 2.0.0-alpha1 | Pre-release | Aug 16, 2024 | ||
| 8.x-1.5 | Stable | May 10, 2023 |