Progress Ring Examples
The examples below assume that you have imported the component and set up the theme.
Basic
Show a known amount of progress. value sets the fill, a data-sv-progress-ring-percentage element shows the number, and inline-size sets the size of the ring.
Reduced Motion
The indeterminate arc sits still at the top of the ring because your system is set to reduce motion.
%
--indeterminate
<div class="ring-basic"> <sv-progress-ring aria-label="Upload progress" value="65"> <p data-sv-progress-ring-value-text> <span data-sv-progress-ring-percentage="0"></span> <span>%</span> </p> </sv-progress-ring></div>
<style> .ring-basic { display: grid; place-content: center;
sv-progress-ring { inline-size: 6rem; }
p { margin: 0; font-size: 0.875rem; }
sv-progress-ring:state(--indeterminate) p { display: none; } }</style>Download
Drive the ring from script as progress arrives. Setting the value property each time animates the fill to the new value.
%
<div class="ring-download"> <sv-progress-ring class="download-ring" aria-label="Download progress" value="0"> <p data-sv-progress-ring-value-text> <span data-sv-progress-ring-percentage="0"></span> <span>%</span> </p> </sv-progress-ring></div>
<script type="application/x-typescript" module> const ring = document.querySelector<ProgressRing>(".download-ring")!;
let speed = 100;
function tick() { const current = ring.value ?? 0; const next = current >= ring.max ? 0 : current + 1;
ring.value = next;
if (Math.random() < 0.1) { speed = 20 + Math.random() * 380; }
setTimeout(tick, next >= ring.max ? 1500 : speed); }
tick();</script>
<style> .ring-download { display: flex; justify-content: center;
sv-progress-ring { inline-size: 6rem; }
p { margin: 0; font-size: 0.875rem; } }</style>