Part of the Twig ecosystem · 43 projects
This module allows you to easily embed inline SVG icons directly within your Twig templates. You can specify the icon name, title, CSS classes, and custom attributes for each SVG.
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.
Ask your assistant about Twig SVG
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
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 | PHP | 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 | 8–10 | Aug 16, 2024 | ||
| 8.x-1.8 | Stable | 8–10 | Aug 16, 2024 | ||
| 8.x-1.7 | Stable | 10–11 | Aug 16, 2024 | ||
| 8.x-1.6 | Stable | 8–11 | Aug 16, 2024 | ||
| 2.0.x-dev | Dev | 10–11 | Aug 16, 2024 | ||
| 2.0.0-alpha1 | Pre-release | 10–11 | Aug 16, 2024 | ||
| 8.x-1.5 | Stable | 8–10 | May 10, 2023 |