You can play with a sample SVG sprite on https://boxy-svg.com/#demo-symbols. Individual icons are shown under "Defs Panel -> Symbols". To edit an icon just double-click its thumbnail. To make part of an icon recolorable, select that part and then click "Fill Panel -> Paint -> Type -> Inherit".
You could then create separate symbols which contain a recolored instance of the original symbol. The underlying markup will look something like this:
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="recolorable" viewBox="0 0 100 100">
<rect width="100" height="100" style="fill: inherit;"/>
</symbol>
<symbol id="blue" viewBox="0 0 100 100">
<use width="100" height="100" style="fill: blue;" xlink:href="#recolorable"/>
</symbol>
<symbol id="green" viewBox="0 0 100 100">
<use width="100" height="100" style="fill: green;" xlink:href="#recolorable"/>
</symbol>
</defs>
</svg>
Finally, use a fragment identifier to show a specific icon in HTML: <img src="sprite.svg#green">To make it work you would have to either replace <img src="sprite.svg#green"/> with <svg ...><use href="sprite.svg#green"></use></svg> or add views to the sprite file:
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="recolorable" viewBox="0 0 100 100">
<rect width="100" height="100" style="fill: inherit;"/>
</symbol>
<view id="blue" viewBox=" 0 0 100 100"></view>
<view id="green" viewBox="100 0 100 100"></view>
</defs>
<use x="0" y="0" width="100" height="100" style="fill: blue;" xlink:href="#recolorable"/>
<use x="100" y="0" width="100" height="100" style="fill: green;" xlink:href="#recolorable"/>
</svg>P.S. I actually went ahead and changed the implementation to a separate file on my website after I saw your comment :D
The icon:
<!-- the icon width is 2x wider, to accommodate both 26x26 variants -->
<svg xmlns="http://www.w3.org/2000/svg" width="52" height="26">
<defs>
<!-- here's the icon defined, you can basically put anything here and
mark it with an id (you can even use another svg) -->
<path id="icon" path="..."/>
</defs>
<!-- first variant with no fill -->
<use stroke="#fff" href="#icon"/>
<!-- second variant with fill, shifted by 26 (dimensions of the icon) -->
<use x="26" fill="#00ACA0" stroke="#00ACA0" href="#a"/>
</svg>
HTML: <!-- make sure you use dimensions of the single variant -->
<img src="icon.svg" width="26" height="26" class="hover-icon">
CSS: .hover-icon {
/* make sure that only first block of the image is visible */
object-fit: cover;
object-position: left;
}
.hover-icon:hover {
object-position: right;
}Btw, for such simple re-colouring I'd probably rather used CSS hue shift filter or similar effect, and kept the SVG "dumb". But for having different shapes or geometric properties this approach is indeed nifty.