There are a few different ways to do this but for your SVG it would probably be to use a linear gradient
(tho this is not a perfect solution, since it's just a linear gradient from left to right and does not follow the arch) But I think it would be sufficient.
.progress-wrapper {
height: 100vh;
display: flex;
align-items: center;
justify-content: space-around;
}
path {
stroke-linecap: round;
stroke-width: 6;
}
.grey {
stroke: #e5e5e5;
stroke-width: 3px;
}
.green {
stroke: url(#arcGradient);
stroke-width: 9px;
stroke-dasharray: 248;
stroke-dashoffset: 240;
/* adjust last number for variance */
&.red-09 {
stroke-dashoffset: 50;
}
}
<div class="progress-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="37 -5 120 100" width="120" height="100">
<defs>
<linearGradient id="arcGradient" gradientUnits="objectBoundingBox">
<stop offset="0%" stop-color="red"/>
<stop offset="20%" stop-color="darkorange"/>
<stop offset="50%" stop-color="khaki"/>
<stop offset="80%" stop-color="yellowgreen"/>
<stop offset="100%" stop-color="limegreen"/>
</linearGradient>
</defs>
<path class="grey" d="M55,90
A55,55 0 1,1 140,90"
style="fill:none;"/>
<path class="green red-09" d="M55,90
A55,55 0 1,1 140,90"
style="fill:none;"/>
</svg>
</div>
I am not sure how you want to control the length of the stroke-dashoffset
. But maybe this would be wise to add either as a style, so you don't need many different classes for every length of the progress bar.
.progress-wrapper {
height: 100vh;
display: flex;
align-items: center;
justify-content: space-around;
}
path {
stroke-linecap: round;
stroke-width: 6;
}
.grey {
stroke: #e5e5e5;
stroke-width: 3px;
}
.green {
stroke: url(#arcGradient);
stroke-width: 9px;
stroke-dasharray: 248;
stroke-dashoffset: 240;
}
<div class="progress-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="37 -5 120 100" width="120" height="100">
<defs>
<linearGradient id="arcGradient" gradientUnits="objectBoundingBox">
<stop offset="0%" stop-color="red"/>
<stop offset="20%" stop-color="darkorange"/>
<stop offset="50%" stop-color="khaki"/>
<stop offset="80%" stop-color="yellowgreen"/>
<stop offset="100%" stop-color="limegreen"/>
</linearGradient>
</defs>
<path class="grey" d="M55,90 A55,55 0 1,1 140,90" style="fill:none;"></path>
<path class="green" d="M55,90 A55,55 0 1,1 140,90" style="fill:none; stroke-dashoffset: 50;"></path>
</svg>
</div>
This way it's also a bit easier to update with, for example JS if this should reflect something the user is doing, client side.
Hope this helps you out. Have a great day!