Morph SVG with <animate> SVG or CSS transition - html
I'm struggling to make an animation work. I've created two SVG shapes in Illustrator with the same amount of path points. Now i want to code a morphing animation. My first try was an animate object as suggested here:
<span class="svgspan">
<svg class="svg1" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 398 369.4"
style="enable-background:new 0 0 398 369.4;" xml:space="preserve">
<style type="text/css">
.st0 {
fill: #FFFFFF;
}
</style>
<path id="pfad" class="st0" d="M398 184.7c0 51-20.7 97.2-54.1 130.6s-79.6 54.1-130.6 54.1s-97.2-20.7-130.6-54.1s-54.1-79.6-54.1-130.6
S49.3 87.5 82.7 54.1S162.3 0 213.3 0s97.2 20.7 130.6 54.1S398 133.7 398 184.7z">
<animate id="trs" begin="500ms" fill="freeze" attributename="d" dur="2s" from ="M398,184.7c0,51-20.7,97.2-54.1,130.6s-79.6,54.1-130.6,54.1s-97.2-20.7-130.6-54.1s-54.1-79.6-54.1-130.6
S49.3 87.5 82.7 54.1S162.3 0 213.3 0s97.2 20.7 130.6 54.1S398 133.7 398 184.7z" to="M195 369.4c-48.4-78-140.4-118.3-182.3-200.3C-3.8 131.7-6.1 85 17.2 50C57.9-16 157.7-15.8 199.1 49.4
c32.3-51.6 107.8-65.7 155.7-27.5c54.5 39.2 53.8 119.8 15.8 170.4c-49 65.4-124.1 107-167.6 177.1H195z"></path>
</svg></span>
I got an animation, but it didn't morph but instantly switch to the second path.
My next approach was a css animation like this:
#pfad {
d: path('M195,369.4c-48.4-78-140.4-118.3-182.3-200.3C-3.8,131.7-6.1,85,17.2,50C57.9-16,157.7-15.8,199.1,49.4c32.3-51.6,107.8-65.7,155.7-27.5c54.5,39.2,53.8,119.8,15.8,170.4c-49,65.4-124.1,107-167.6,177.1H195z');
transition: 1s;
}
This didn't work either. I even got an 'Unknown property: d' error in VS Code and Chrome:
It would be nice if someone could help me get this working.
Edit: The anchor points are in the right position now i guess, but i still have the same problem. New anchor points:
<path id="pfad" class="st0" d="M199,369.4c-57.6-0.5-110.6-27.4-144.1-69.2c-25.4-31.6-40.6-71.8-40.6-115.5C14.3,82.7,97,0,199,0
s184.7,82.7,184.7,184.7c0,33.7-9,65.3-24.8,92.5C326.9,332.3,267.3,369.4,199,369.4C198.4,369.4,199.6,369.4,199,369.4z">
<animate id="trs" begin="500ms" fill="freeze" attributename="d" dur="2s" from ="M199,369.4c-57.6-0.5-110.6-27.4-144.1-69.2c-25.4-31.6-40.6-71.8-40.6-115.5C14.3,82.7,97,0,199,0
s184.7,82.7,184.7,184.7c0,33.7-9,65.3-24.8,92.5C326.9,332.3,267.3,369.4,199,369.4C198.4,369.4,199.6,369.4,199,369.4z" to="M199,369.4C150.6,291.4,54.8,251,12.9,169C-3.6,131.6-5.9,84.9,17.4,49.9c40.7-66,140.5-65.8,181.9-0.6
C231.6-2.3,307.1-16.4,355,21.8c54.5,39.2,53.8,119.8,15.8,170.4C321.8,257.6,242.5,299.3,199,369.4L199,369.4z"></path>```
Like the comments suggest, it is a good idea to be precise with the point in the path. So, your code is ok. It is just the path that need a helping hand.
I copied your path to Inkscape and make the two shapes there.
path {
fill: red;
}
<span class="svgspan">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="200" height="200">
<path id="pfad" class="st0"
d="M 500,1000 C 220,1000 0,780 0,500 0,220 220,0 500,0 c 280,0 500,220 500,500 0,280 -220,500 -500,500 z">
<animate id="trs" begin="1s" fill="freeze" attributename="d" dur="2s"
from ="M 500,1000 C 220,1000 0,780 0,500 0,220 220,0 500,0 c 280,0 500,220 500,500 0,280 -220,500 -500,500 z"
to="M 500,1000 C 420,820 0,600 0,300 0,0 380,-120 500,150 620,-120 1000,0 1000,300 c 0,300 -420,520 -500,700 z" />
</path>
</svg>
</span>
The main condition for the implementation of smooth animation path changes
using the attribute d are:
Equal number of nodes in both shapes
Exact match of the node type (A; C; Q), respectively, for each point in the initial and final position of the path
These conditions can be met in different ways, but it is better to do this in the vector editor.
You must have the same number of node points by the heart and the circle
Below is a screenshot from Inkscape. Drag matching points from the outline of the heart to the outline of the circle
#chrwahl did this work in his answer while solving this problem
All credits to #chrwahl for a job well done
#jayjay9601 comments
I'll definitely try that even though i would prefer the html/css-only
version
Below is the complete CSS animation code using the d attribute:
.svgspan {
width:30vw;
height:30vh;
}
#pfad{
fill: crimson;
transition: all 1s ease-in-out;
}
#pfad:hover {
d: path("M 500,1000 C 420,820 0,600 0,300 0,0 380,-120 500,150 620,-120 1000,0 1000,300 c 0,300 -420,520 -500,700 z");
fill: red;
}
<div class="svgspan">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" >
<path id="pfad" class="st0"
d="M 500,1000 C 220,1000 0,780 0,500 0,220 220,0 500,0 c 280,0 500,220 500,500 0,280 -220,500 -500,500 z">
</path>
</svg>
</div>
Related
How to change position of SVG path (elliptical arc) with CSS
I'm looking to change position of a few created SVG shapes with CSS. I've had no trouble positioning them from the beginning, and I've been able to re-position other objects like rectangles and circles with CSS. But I can't figure out how to do it with a path. I've done searches both here and through Google search for several hours, but haven't found any usable clues. I'm beginning to suspect that there is something about SVG paths I haven't understood fully yet, but at the same time I can't help but think that it might just be down to me not understanding the correct syntax in CSS. Below is an SVG elliptical arc path I've created. I'd like to move it anywhere within view (so I can spot the difference and work from there). Can someone tell me if I'm lacking some knowledge about how paths work (contrary to how rectangles work in this regard), or if I just need the proper syntax in CSS? Please note: I do NOT want to animate it in any way, just move it to a new position if possible. <svg xmlns="http://www.w3.org/2000/svg"> <path id="cockpit" d="M 0 0 A 50 37.5 0 0 1 50 0" fill="lightblue" stroke="blue" stroke-width="1" stroke-miterlimit="5"/> </svg>
You can move the path using transform/translate either as a CSS property (first example) or as an attribute (second example). I also added the viewBox attribute to the SVG element -- then it's easier to see where you place the path in the SVG. svg { background: orange; } path { transform: translate(10px, 10px); } <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 20"> <path id="cockpit" d="M 0 0 A 50 37.5 0 0 1 50 0" fill="lightblue" stroke="blue" stroke-width="1" stroke-miterlimit="5"/> </svg> svg { background: orange; } <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 20"> <path id="cockpit" d="M 0 0 A 50 37.5 0 0 1 50 0" fill="lightblue" stroke="blue" stroke-width="1" stroke-miterlimit="5" transform="translate(10 10)" /> </svg>
The capital A in your path M 0 0 A 50 37.5 0 0 1 50 0 makes it Arc at an absolute position If you convert that whole path to use a relative a position: M0 0 a 50 37.5 0 0 1 50 0 (use https://yqnn.github.io/svg-path-editor/# for more complex paths) You can use the first M x y notation to position the path anywhere in the viewBox <style> svg { background:hotpink; height:50px } path { fill:lightblue; stroke:blue } </style> <svg viewBox="0 0 55 10"> <path d="M 0 7 a 50 37.5 0 0 1 50 0" /> </svg> <svg viewBox="0 0 55 10"> <path d="M 14 7 a 50 37.5 0 0 1 50 0" /> </svg> <svg viewBox="0 0 55 10"> <path d="M 4 9 a 50 37.5 0 0 1 50 0" /> </svg> <svg viewBox="0 0 55 10"> <path d="M 4 12 a 50 37.5 0 0 1 50 0" /> </svg>
I finally got on track with 'offset-path', and with some tinkering I managed to understand enough about how it works to move the path to a new position: offset-path: path("M237.5 50");
How to animate an object with <img> tag move along a path?
I want to create an animation in which an object (in this case, the first blue line in the image https://i.stack.imgur.com/RDwQ2.png) move along an svg path. The line is provided in the form of PNG. I tried using the tag but it's not changing anything. Here is basically an example of what I wanted animate image on SVG Path. Below is my code. <svg height="238.158mm" viewbox="0 0 1920 900" width="508.071mm" xmlns="http://www.w3.org/2000/svg"> <path class="green-line" d="M 1.09,741.82 C 1.09,741.82 17.09,734.00 17.09,734.00 17.09,734.00 51.45,718.73 51.45,718.73 51.45,718.73 74.55,709.09 74.55,709.09 74.55,709.09 110.91,694.73 110.91,694.73 110.91,694.73 157.45,678.18 157.45,678.18 157.45,678.18 199.82,665.27 199.82,665.27 199.82,665.27 253.82,650.55 253.82,650.55 253.82,650.55 312.67,638.00 312.67,638.00 312.67,638.00 387.67,627.33 387.67,627.33 387.67,627.33 453.33,621.00 453.33,621.00 453.33,621.00 505.33,618.67 505.33,618.67 505.33,618.67 576.67,620.33 576.67,620.33 576.67,620.33 619.33,623.67 619.33,623.67 619.33,623.67 636.67,625.00 636.67,625.00 636.67,625.00 715.67,636.33 716.00,636.33 716.33,636.33 783.00,648.33 783.00,648.33 783.00,648.33 846.67,665.00 846.67,665.00 846.67,665.00 895.33,679.00 895.33,679.00 895.33,679.00 951.33,697.67 951.33,697.67 951.33,697.67 1026.00,723.33 1026.00,723.33 1026.00,723.33 1097.33,747.67 1097.33,747.67 1097.33,747.67 1176.67,776.00 1176.67,776.00 1176.67,776.00 1236.67,798.00 1236.67,798.00 1236.67,798.00 1265.00,807.67 1265.00,807.67 1265.00,807.67 1316.00,826.55 1316.00,826.55 1316.00,826.55 1351.64,837.27 1351.64,837.27 1351.64,837.27 1389.09,847.82 1389.09,847.82 1389.09,847.82 1429.45,858.36 1429.45,858.36 1429.45,858.36 1452.91,863.82 1452.91,863.82 1452.91,863.82 1470.81,868.06 1470.81,868.06 1470.81,868.06 1489.88,872.06 1489.88,872.06 1489.88,872.06 1503.88,874.25 1503.88,874.25 1503.88,874.25 1513.50,875.94 1513.50,875.94 1513.50,875.94 1533.44,879.31 1533.44,879.31 1533.44,879.31 1546.38,881.56 1546.38,881.56 1546.38,881.56 1556.19,883.00 1556.19,883.00 1556.19,883.00 1566.19,884.19 1566.19,884.19 1566.19,884.19 1596.69,887.69 1596.69,887.69 1596.69,887.69 1614.12,889.88 1614.12,889.88 1614.12,889.88 1633.06,891.12 1633.06,891.12 1633.06,891.12 1645.25,892.25 1645.25,892.25 1645.25,892.25 1682.62,895.06 1682.62,895.06 1682.62,895.06 1693.31,896.12 1693.31,896.12 1693.31,896.12 1707.22,897.04 1707.22,897.04 1707.22,897.04 1723.17,897.78 1723.17,897.78 1723.17,897.78 1729.09,898.22 1729.09,898.22 1729.09,898.22 1763.43,899.22 1763.43,899.22 1763.43,899.22 1768.74,899.48 1768.78,899.48 1768.83,899.48 1774.59,899.56 1774.59,899.56 1774.59,899.56 1778.34,899.88 1778.34,899.88 1778.34,899.88 1779.50,899.97 1779.50,899.97 1779.50,899.97 1793.39,899.91 1793.39,899.91 1793.39,899.91 1807.48,899.96 1807.48,899.96 1807.48,899.96 1817.13,900.00 1817.13,900.00 1817.13,900.00 1822.35,899.83 1822.43,899.87 1822.52,899.91 1884.73,899.91 1884.73,899.91 1884.73,899.91 1897.73,899.91 1897.73,899.91 1897.73,899.91 1918.64,900.27 1918.64,900.27 1918.64,900.27 1919.62,900.00 1919.62,900.00" id="animatePath" style="fill:none;stroke:none ;stroke-miterlimit:10;"> </path> <image height="250px" id="car" width="1918px" x="0" xlink:href="/data/cms/images/1668585137_img-top-panel-curve.png" y="500"> <animatemotion begin="0s" dur="20s" repeatcount="indefinite" restart="whenNotActive" xlink:href="#car"> <mpath xlink:href="#animatePath"> </mpath> </animatemotion> </image> </svg> </div>
Svg height greater than path height
I'm trying to make the top edge of a website footer wavvy by using a svg. My svg: <svg id="footer_svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1335 190.97"> <path class="cls-2" d="M924.04,146.21c-76.43,5.57-72.82,6.94-181.21,15.68-101.37,8.17-186.53,15.03-294.66,19.39-127.28,5.13-225.98,4.36-297.61,3.71-44.28-.4-94.82-1.28-150.55-3v10.98H1335v-63.26c-40.08,.65-76.99,1.52-110.4,2.47-84.89,2.41-179.64,5.22-300.56,14.03Z"></path> </svg> For some reason, the svg ends up with height=272.22px but the path height=90.17px. I can't see any css settings that interferes with anything here. Here's the result I'm getting: I want to get rid of this extra white space: . Can anyone advise please? NB: I'm not very experienced and have rarely used svgs before so it's very possible I've left something out or I've overlooked something. I've already tried looking this up but couldn't come up with a solution. All I can find is in relation to making the path the same height as the svg element but I want to achieve the opposite. Many thanks!
The width and en height of the viewbox should match the size of the elements in the SVG. Your path has a height of 63.26, so here I moved up the path shape and made the height of the viewbox 63.26. <svg id="footer_svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1335 63.26"> <path class="cls-2" d="M 924.04 16.5 c -76.43 5.57 -72.82 6.94 -181.21 15.68 c -101.37 8.17 -186.53 15.03 -294.66 19.39 c -127.28 5.13 -225.98 4.36 -297.61 3.71 c -44.28 -0.4 -94.82 -1.28 -150.55 -3 v 10.98 H 1335 v -63.26 c -40.08 0.65 -76.99 1.52 -110.4 2.47 c -84.89 2.41 -179.64 5.22 -300.56 14.03 Z"></path> </svg>
Use preserveAspectRatio="none": svg { width: 500px; height: 50px; } <svg viewBox='0 0 100 100' preserveAspectRatio="none"> <path d="M 0,80 C 50,120 50,-50 100,20 V 100 H 0 Z" fill='lightblue' /> </svg>
Using CSS variable in CSS rotate function
I am developing an SVG image of a snowman and I am trying to use variables to determine specific things. The color of the strap thing on the hat and the color of the scarf are successfully set by var(--maincolor). What I am having trouble with is var(--armangle). <path d="..." stroke="#442200" stroke-width="2" fill="none" transform="rotate(var(--armangle))" transform-origin="32.5% 60%"/> Why doesn't it get accepted? I have tried: svg{ --armangle: 20deg; } and svg{ --armangle: 20; } but neither work at all. Is there a way to use a variable in a function in CSS? A normal value (without deg) works (deg just gets ignored) very well.
You should use either attributes or CSS for styling. As you can see from the two examples styling can either be defined as part of the SVG or in a separate stylesheet. When using CSS variables/values need to specify that it is a number of degrees (like 20deg). :root { --armangle: 20deg; } <svg viewBox="0 0 3 3" width="200" height="200"> <style> path { transform: rotate(var(--armangle)); } </style> <path d="M 0 0 L 0 1 L 1 1 L 1 0 Z" stroke="#442200" stroke-width=".1" fill="none" transform-origin="32.5% 60%"/> </svg> :root { --armangle: 20deg; } svg > path { transform: rotate(var(--armangle)); } <svg viewBox="0 0 3 3" width="200" height="200"> <path d="M 0 0 L 0 1 L 1 1 L 1 0 Z" stroke="#442200" stroke-width=".1" fill="none" transform-origin="32.5% 60%"/> </svg>
How can I change the color of this SVG?
I'm trying to change the color of this SVG icon with CSS: <symbol id="meetings"> <svg viewBox="9 0 33 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(10.000000, 0.000000)"> <polygon id="Fill-1" points="0.484430769 31.5076923 31.9921231 31.5076923 31.9921231 0 0.484430769 0"></polygon> <g id="Group-4" transform="translate(0.000000, 5.907692)"> <path d="M4.92209231,11.8248862 C4.31409231,11.8248862 2.46006154,10.3154708 2.46006154,6.70390154 C2.46006154,2.47251692 4.8896,0.00704 7.79470769,0.00704 C9.18498462,0.00704 9.83926154,0.0715323077 10.5846154,0.745993846 C12.7123692,0.745993846 14.7702154,2.32433231 14.7702154,6.70390154 C14.7702154,10.2869169 12.9353846,11.8248862 12.3081846,11.8248862 C12.0900923,11.8248862 11.9241846,11.6338708 11.6795077,11.3847631 C11.4304,11.6328862 11.1547077,11.8539323 10.8583385,12.0439631 C10.9883077,13.9743015 11.7257846,14.7536246 13.8594462,15.5452554 C16.0896,16.3728246 17.1037538,16.9429169 17.2332308,19.1730708 C17.2494769,19.4477785 17.0402462,19.6831015 16.7655385,19.6993477 C16.7566769,19.69984 16.7483077,19.69984 16.7394462,19.69984 L0.494769231,19.69984 C0.219569231,19.6983631 -0.00147692308,19.4738708 2.03980422e-13,19.1991631 C2.03980422e-13,19.1903015 0.000492307693,19.1819323 0.000984615385,19.1730708 C0.130953846,16.9429169 1.14461538,16.3728246 3.37526154,15.5452554 C5.50793846,14.7541169 6.24541538,13.9747938 6.37538462,12.0464246 C6.07606154,11.8549169 5.79790769,11.6319015 5.54633846,11.3808246 C5.29969231,11.6314092 5.13476923,11.8248862 4.92209231,11.8248862 M31.0129231,19.69984 L18.6973538,19.6983631 C18.4369231,19.6993477 18.2212923,19.4960246 18.2070154,19.2355938 C18.2178462,18.26624 17.9244308,17.3180554 17.3671385,16.5244554 C17.1515077,16.2615631 17.1899077,15.8736246 17.4532923,15.6579938 C17.5035077,15.61664 17.5606154,15.5831631 17.6216615,15.5600246 L17.6605538,15.5452554 C19.7971692,14.7516554 20.5326769,13.9703631 20.6596923,12.0301785 C20.2904615,11.7933785 19.9571692,11.5053785 19.6696615,11.1745477 C19.1537231,10.5055015 18.8292923,9.70944 18.7308308,8.87054769 C18.7067077,8.87300923 18.6825846,8.87497846 18.6589538,8.87497846 C18.1243077,8.87497846 17.7196308,7.74759385 17.7196308,6.95497846 C17.7196308,6.16236308 17.9943385,5.92113231 18.2562462,5.92113231 C18.3108923,5.92113231 18.3616,5.92408615 18.4108308,5.92802462 C18.2872615,5.43030154 18.2217846,4.92027077 18.2153846,4.40777846 C18.2153846,2.48580923 18.7544615,1.15559385 20.4007385,0.918793846 C21.312,0.286670769 22.6894769,0.00753230769 24.4494769,0.00753230769 C25.5748923,0.00753230769 24.6370462,0.777501538 25.6950154,1.00248615 C26.3497846,1.14180923 27.5687385,1.60556308 27.5687385,4.40777846 C27.5623385,4.92027077 27.4968615,5.43030154 27.3732923,5.92802462 C27.4220308,5.92408615 27.4732308,5.92113231 27.5278769,5.92113231 C27.7902769,5.92113231 28.0644923,6.16236308 28.0644923,6.95497846 C28.0644923,7.74759385 27.6603077,8.87497846 27.1256615,8.87497846 C27.1015385,8.87497846 27.0774154,8.87300923 27.0532923,8.87054769 C26.9548308,9.70944 26.6304,10.5055015 26.1144615,11.1745477 C25.8299077,11.5019323 25.5005538,11.7874708 25.1357538,12.0227938 C25.2612923,13.9688862 25.9958154,14.7511631 28.1353846,15.5452554 C30.3635692,16.3728246 31.3767385,16.9429169 31.5062154,19.1730708 C31.5224615,19.4472862 31.3137231,19.6831015 31.0395077,19.6993477 C31.0306462,19.69984 31.0217846,19.69984 31.0129231,19.69984" id="Fill-2"></path> </g> </g> </svg> I'm using that SVG in the HTML like this: <svg class="active" width="32px" height="32px"> <use xlink:href="#meetings"/></use> </svg> Here is the CSS (using SASS): .foot__icon svg.active { fill: #ffffff !important; path, g, #Group-4 { fill: #ffffff !important; } } This isn't working and I can't figure out why. When I try to remove the fill declaration from the g tag (fill="#03A9F4") then the SVG disappears completely. The active class is even showing up in dev tools but the color is not showing up white Update: This seems to be an issue with the <use> tag. If I put the class directly on the SVG, then it works as expected. Still not sure what's going on here.
When you reference something via a <use>, the referenced elements don't suddenly become part of the DOM "under" the <use> element. In other words, the DOM still remains like this <symbol id="meetings"> <path> <svg class="active"> <use> Not <svg class="active"> <use> <symbol id="meetings"> <path> So a CSS rule like svg.active path won't work. Symbols are meant to be static copies of an element, or set of elements that are reused. If you want to style them, you should style the original symbol. For instance: #Group-4 { fill: #ffffff; } If you want to dynamically style the symbol then there is one limited solution you can use. There is a special keyword value for SVG colors named currentColor, which allows you to use the current value of color for the fill or stroke. This "trick" allows us to pass a single colour into the symbol. In the example below I am using it to colour the path in the symbol. #Group-4 { fill: currentColor; } svg.active { color: red; } svg.inactive { color: lightgrey; } <svg width="0" height="0"> <symbol id="meetings" viewBox="9 0 33 32"> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(10.000000, 0.000000)"> <polygon id="Fill-1" points="0.484430769 31.5076923 31.9921231 31.5076923 31.9921231 0 0.484430769 0"></polygon> <g id="Group-4" transform="translate(0.000000, 5.907692)"> <path d="M4.92209231,11.8248862 C4.31409231,11.8248862 2.46006154,10.3154708 2.46006154,6.70390154 C2.46006154,2.47251692 4.8896,0.00704 7.79470769,0.00704 C9.18498462,0.00704 9.83926154,0.0715323077 10.5846154,0.745993846 C12.7123692,0.745993846 14.7702154,2.32433231 14.7702154,6.70390154 C14.7702154,10.2869169 12.9353846,11.8248862 12.3081846,11.8248862 C12.0900923,11.8248862 11.9241846,11.6338708 11.6795077,11.3847631 C11.4304,11.6328862 11.1547077,11.8539323 10.8583385,12.0439631 C10.9883077,13.9743015 11.7257846,14.7536246 13.8594462,15.5452554 C16.0896,16.3728246 17.1037538,16.9429169 17.2332308,19.1730708 C17.2494769,19.4477785 17.0402462,19.6831015 16.7655385,19.6993477 C16.7566769,19.69984 16.7483077,19.69984 16.7394462,19.69984 L0.494769231,19.69984 C0.219569231,19.6983631 -0.00147692308,19.4738708 2.03980422e-13,19.1991631 C2.03980422e-13,19.1903015 0.000492307693,19.1819323 0.000984615385,19.1730708 C0.130953846,16.9429169 1.14461538,16.3728246 3.37526154,15.5452554 C5.50793846,14.7541169 6.24541538,13.9747938 6.37538462,12.0464246 C6.07606154,11.8549169 5.79790769,11.6319015 5.54633846,11.3808246 C5.29969231,11.6314092 5.13476923,11.8248862 4.92209231,11.8248862 M31.0129231,19.69984 L18.6973538,19.6983631 C18.4369231,19.6993477 18.2212923,19.4960246 18.2070154,19.2355938 C18.2178462,18.26624 17.9244308,17.3180554 17.3671385,16.5244554 C17.1515077,16.2615631 17.1899077,15.8736246 17.4532923,15.6579938 C17.5035077,15.61664 17.5606154,15.5831631 17.6216615,15.5600246 L17.6605538,15.5452554 C19.7971692,14.7516554 20.5326769,13.9703631 20.6596923,12.0301785 C20.2904615,11.7933785 19.9571692,11.5053785 19.6696615,11.1745477 C19.1537231,10.5055015 18.8292923,9.70944 18.7308308,8.87054769 C18.7067077,8.87300923 18.6825846,8.87497846 18.6589538,8.87497846 C18.1243077,8.87497846 17.7196308,7.74759385 17.7196308,6.95497846 C17.7196308,6.16236308 17.9943385,5.92113231 18.2562462,5.92113231 C18.3108923,5.92113231 18.3616,5.92408615 18.4108308,5.92802462 C18.2872615,5.43030154 18.2217846,4.92027077 18.2153846,4.40777846 C18.2153846,2.48580923 18.7544615,1.15559385 20.4007385,0.918793846 C21.312,0.286670769 22.6894769,0.00753230769 24.4494769,0.00753230769 C25.5748923,0.00753230769 24.6370462,0.777501538 25.6950154,1.00248615 C26.3497846,1.14180923 27.5687385,1.60556308 27.5687385,4.40777846 C27.5623385,4.92027077 27.4968615,5.43030154 27.3732923,5.92802462 C27.4220308,5.92408615 27.4732308,5.92113231 27.5278769,5.92113231 C27.7902769,5.92113231 28.0644923,6.16236308 28.0644923,6.95497846 C28.0644923,7.74759385 27.6603077,8.87497846 27.1256615,8.87497846 C27.1015385,8.87497846 27.0774154,8.87300923 27.0532923,8.87054769 C26.9548308,9.70944 26.6304,10.5055015 26.1144615,11.1745477 C25.8299077,11.5019323 25.5005538,11.7874708 25.1357538,12.0227938 C25.2612923,13.9688862 25.9958154,14.7511631 28.1353846,15.5452554 C30.3635692,16.3728246 31.3767385,16.9429169 31.5062154,19.1730708 C31.5224615,19.4472862 31.3137231,19.6831015 31.0395077,19.6993477 C31.0306462,19.69984 31.0217846,19.69984 31.0129231,19.69984" id="Fill-2"></path> </g> </g> </symbol> </svg> <svg class="active" width="32px" height="32px"> <use xlink:href="#meetings"/> </svg> <svg class="inactive" width="32px" height="32px"> <use xlink:href="#meetings"/> </svg> So we are setting the symbol's path to fill: currentColor, and then setting color to red for svg.active. The red gets passed into the symbol and used for the path. And just to prove it is dynamic, I've added another reference to the symbol, with class "inactive", and made that one a different colour.