Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

SVG Sprite

19 sites Security covered
View on drupal.org

This module allows you to manage and display icons from SVG sprite files. It provides a field type to select icons from a dropdown, automatically populated from your sprite's symbol IDs. Icons can then be easily inserted into content or Twig templates.

This module adds a new field type called SVG Sprite. Using this field you can select an icon from a dropdown list which is auto-generated from a SVG Sprite file.

It reads the SVG Sprite and automatically adds every <symbol id="">...</symbol> to the list, which is typically how SVG Sprites are generated.

It outputs something similar to file.svg#symbol-id using a dedicated field formatter.

A submodule is available to allow insertion of SVG sprites in CKEditor 5 WYSIWYG editor.

A small Twig extension is also available allowing to easily add an SVG sprite into your Twig templates.

Example: {{ svg_sprite('lightbulb') }}.

You can add custom attributes to your sprite Twig function:

{{ svg_sprite('lightbulb', {'class': 'my_css_class'}) }}

This will produce:

<svg class="sprite sprite-lightbulb my_css_class"...>
  ...
</svg>

An experimental token is also available: [svg_sprite:sprite:lightbulb] but might requires to allow svg and use HTML tags rendering in some contexts like Views (XSS).

A small utility function in the SvgSpriteHelper class shows how to programmatically override the Xss::$adminTags property to allow the use of the svg and use HTML tags.

Similar or related projects

Activity

Total releases
5
First release
Oct 2025
Latest release
4 months ago
Releases (12 mo)
5 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.1.5 Stable Mar 10, 2026
1.1.4 Stable Nov 19, 2025
1.x-dev Dev Nov 17, 2025
1.1.3 Stable Nov 17, 2025
1.1.2 Stable Oct 10, 2025