This module provides a way to upload and manage SVG icons within Drupal. You can then display these icons on your website using Twig templates or as formatted fields, and even generate CSS sprites from your uploaded icons.
Icon Select Module
This module allows you to upload and display SVG icons in the drupal backend. You can display these icons in your frontend theme using twig or render them as a fields.
Usage
- Install the module using composer. This is important, because it will download a dependancy of SVGSanitizer. It will create a new vocabulary called "icons".
- On the vocabulary, you can configure the path of the svg map in the public files folder.
- Add some icons by using the "Add term" functionality. Please use SVGs that contain strokes and not just paths.
- Create an entity reference field to a taxonomy term using the "icons" vocabulary
- Change the Field Widget from "Autocomplete" to "Icon Select" and you will get a nice icon picker on the target entity
- Change the Field Formatter to "SVG Icon"
Using icons in Twig templates
For all the frontend developers, I added a Twig Extension to easily add an svg icon somewhere in a theme or a module
The second parameter is optional.
{{ svg_icon('symbol-id', 'class1, class2') }}
Example:
{{ svg_icon('ui-check', 'icon--large') }}
Generate css sprites using drush command
drush generate-sprites
This will generates a sprite css from the icons/svgs folder
and place it in icons/css.
Ask your assistant about Icon Select
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
- field Drupal core
- file Drupal core
- taxonomy Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 3.0.2 | Stable | 10–11 | Oct 1, 2026 | ||
| 3.0.1 | Stable | 10–11 | Sep 27, 2024 | ||
| 3.0.0 | Stable | 8–9 | Sep 27, 2024 | ||
| 3.0.0-beta3 | Pre-release | 9–10 | Oct 3, 2023 | ||
| 2.0.3 | Stable | 9–10 | Oct 3, 2023 | ||
| 3.0.0-beta2 | Pre-release | 9–10 | Aug 17, 2023 | ||
| 3.0.0-beta1 | Pre-release | 9–10 | Aug 17, 2023 | ||
| 2.1.0-beta2 | Pre-release | 9–10 | Mar 31, 2023 | ||
| 2.1.0-beta1 | Pre-release | 9–10 | Mar 31, 2023 |