DataPremium

Circular Progress SVG

A single-colour SVG progress ring: it fills up to its value when it appears, follows every new value, and its hue can tell the state.

SVGCSSJS

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →

3 usage examples

Prep before service — a restaurant kitchen's morning checklist — Circular Progress SVG example 1

① Prep before service — a restaurant kitchen's morning checklist

WhenOn the kitchen tablet, six tasks to tick before noon. On the right, the ring moves one notch per box: 67%, 83%, then 100%; it then turns from orange to green and the message becomes "Ready for service".
WhyThe chef sees the state of prep at a glance from the other end of the kitchen. The colour change at 100% says "all good" faster than a sentence.
Settingsaria-valuemax="6" and aria-valuenow = number of ticked boxes, --cprg-size:136px, --cprg-stroke:9, --cprg-duration:.7s, arc #e08a1e then #2f8f57 through a class once everything is ticked. In the scene, a click outside the list ticks the next task.
Ink levels of a printer — status page of an office fleet — Circular Progress SVG example 2

② Ink levels of a printer — status page of an office fleet

WhenThe status page of a colour printer lines up four small rings, one per cartridge, each in the colour of its ink: cyan 62%, magenta 18%, yellow 80%, black 45%. Under magenta, the words "order now".
WhyOne flat colour per ring is exactly what a cartridge calls for: cyan is cyan. You spot the shortest arc without reading a single number.
SettingsFour 78 px rings, --cprg-stroke:11, --cprg-duration:1.3s, one --cprg-color per ink (#0aa5c7, #d6297f, #e3b008, #1f2732), light grey track. In the scene, the rings start at 0 and receive their level on the first pointer move, like a reply from the printer.
Paid parking: time left and an "Add 30 min" button — parking meter app — Circular Progress SVG example 3

③ Paid parking: time left and an "Add 30 min" button — parking meter app

WhenThe screen of a parking session in progress: a large ring shows the share of paid time that is left, with "21 min" in the centre. It is red; "Add 30 min" tops it up and it turns orange, then blue.
WhyRemaining time is a quantity that shrinks, and urgency reads in the hue before the number. Watching the ring top up confirms the payment really extended the stay.
Settings--cprg-size:188px, --cprg-stroke:7, --cprg-duration:.8s, no .cprg-value: free text sits in the centre. aria-valuemax = minutes paid, aria-valuenow = minutes left; red under 20%, orange under 40%, blue above, through classes. In the scene, a click anywhere counts as the button.

How it works

Two stacked SVG circles inside a square .cprg-circle: the track, and the .cprg-bar arc, whose stroke is one dash as long as the whole circumference (314.16 units for a radius of 50). The script shifts that dash according to the value: at 75%, a quarter stays hidden. Both ends of the arc are rounded.

The value is read from aria-valuenow, between aria-valuemin and aria-valuemax: "18 out of 24" gives 75% with no maths on your side. The percentage in the centre is written in the page language ("75%" in English, "75 %" in French) and copied into aria-valuetext.

The ring stays empty until it is half visible, then fills in 2 s. After that, every value written to aria-valuenow makes it glide, forwards or backwards; the text changes straight away.

The arc colour sits in one variable, --cprg-color. A class on the root is enough to go from orange to green when everything is done, or to red below a threshold: the hue switches at once, with no fade.

Accessibility

  • A real progress indicator: role="progressbar", named by aria-label ("Progress", to replace with yours), bounds and value exposed; the SVG drawing is hidden from screen readers.
  • Reduced motion: the stroke transition is turned off and the arc takes its length directly.
  • Colour is not enough: if the hue signals a state (low, full), back it with a word next to it, such as "order now". The percentage stays readable in the centre.
  • Keyboard: the ring displays, it is not operated; it never takes focus.
  • Centre text: white originally (--cprg-text). On a light background, change it: it does not adapt by itself.

Browser compatibility

SVG strokes styled in CSS (stroke-dasharray, stroke-dashoffset driven by a variable), IntersectionObserver, MutationObserver, Intl.NumberFormat. In Chromium 149, Firefox 151 and WebKit 26.5: stroke offset from 314.16 (empty) to 78.54 (75%), one copy moved to 20% without touching the other, value 130 clamped to 100%, ring without centre text accepted.

Chrome 51+✓ Full (measured)
Firefox 55+✓ Full (measured)
Safari 12.1+✓ WebKit engine measured, not checked in real Safari
Edge 79+✓ Full (Chromium engine)
Safari iOS 12.2+✓ Not checked on a real device
Chrome Android 51+✓ Full (Chromium engine)

Without JavaScript the ring stays empty and the text written in the HTML ("75%") is shown as is. Without IntersectionObserver, it fills as soon as the page loads.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0234-root">
  <div class="cprg-circle" role="progressbar" aria-label="Progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75">
    <svg class="cprg-svg" viewBox="0 0 120 120" aria-hidden="true" focusable="false">
      <circle class="cprg-track" cx="60" cy="60" r="50"></circle>
      <circle class="cprg-bar" cx="60" cy="60" r="50"></circle>
    </svg>
    <span class="cprg-value">75%</span>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
aria-valuenow (HTML) 75 Displayed value; writing it again makes the arc glide.
aria-valuemin, aria-valuemax (HTML) 0, 100 Bounds. A value outside them is clamped to 0% or 100%.
.cprg-value (HTML) present Percentage in the centre. Remove the element for a bare ring or to put your own text there.
--cprg-color (CSS) #6366f1 Flat colour of the arc.
--cprg-track, --cprg-text (CSS) indigo at 20%, white Track colour and centre text colour.
--cprg-size (CSS) 120px Diameter; the text follows, at 20% of the diameter.
--cprg-stroke (CSS) 8 Stroke thickness, unitless: in parts of the drawing, which is 120 wide. 8 gives a stroke one fifteenth of the diameter.
--cprg-duration (CSS) 2s Duration of the fill and of every glide.
--cprg-bg, --cprg-height (CSS) #0a0a0f, 300px Background and minimum height of the block that centres the ring.

FAQ

Very little, and it is better to know before getting both: same structure, same script, same settings. Progress Ring draws the arc with a two-colour SVG gradient; this one uses a flat colour, with no <defs> and no id in the HTML. Pick this one when the hue has to mean something (a state, a brand, an ink), the other for a more decorative look.
Remove .cprg-value: the script does without it. Put your own element inside .cprg-circle (it is position: relative) and centre it: "21 min", "18 / 24", an icon. aria-valuetext remains a percentage; that is what screen readers announce.
The script does not do it. When you write the value, add or remove a class on .fx-0234-root and give it its colour: .fx-0234-root.is-low { --cprg-color: #ef4444 }. The variable must be set on the root or below: on a parent, it is overridden by the original value.