{{#each preview}}
<div class="mod_svgsprite">
<h3 class="title">Sprite Name: {{@key}}</h3>
<ul class="list">
{{#each this}}
<li class="item">
<svg class="icon var_{{this}}" focusable="false">
<use xlink:href="#{{this}}" />
</svg>
<span>
{{this}}
</span>
</li>
{{/each}}
</ul>
</div>
{{/each}}
List of all icons used in SVG sprites. SVGs are grouped in folders based on their usage. Sprites can be added to default.data.js
to be included on all pages by default.
To be able to use SVG sprites, follow the steps below.
media:svgsprite
gulp task to your project. Remember to configure paths to your SVG assets.svgspriteloader.js
helper to source/assets/js/helpers
.data-svgsprites-options
attribute in the body
tag that contains the list of path to SVG sprites you want to use.To use an icon from SVG sprite:
Make sure the group that contains this icon is listed in the data-svgsprites-options
attribute of body
element. If not, add a path to the group.
<body data-svgsprites-options="['../../assets/media/svg/base.svg',{{path to needed group}}]">
Add the html snippet below to the module or page. Replace icon
with the name of the icon you want to use and class
with whatever CSS class you need.
<svg class="{{class}}" focusable="false">
<use xlink:href="#{{icon}}" />
</svg>
Instead of defining sprites in the data-svgsprites-options
of the body, using svgsprites_loader.js
and referencing the icons relatively, they can be referenced explicitly:
```html
<svg class="{{class}}" focusable="false">
<use xlink:href="../../../assets/media/svg/base.svg#{{icon}}" />
</svg>
```
This simplifies the setup a lot, however, the backend would need to update the xlink:href
attribute whenever an icon is moved between sprites, e.g.