DataPremium

Gauge Meter CSS

A half-circle gauge made of plain CSS borders: the arc fills up to the value written in the HTML, in a single colour, and still works with JavaScript turned off.

CSSBorder

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

Heat of three mustards — product page of a craft mustard mill — Gauge Meter CSS example 1

① Heat of three mustards — product page of a craft mustard mill

WhenOn the page of a mustard sold in three varieties, each tab has its gauge: “Mild” in green at a quarter, “Bold” in orange halfway, “Hot” in red almost at the end. Switching tabs shows the other panel and its gauge fills.
WhyA mustard's heat is not a number, it sits somewhere between “mild” and “hot”: a half-circle with a word in the middle says it better than a score out of five. And since the gauge restarts on every display, the tabs need no code.
SettingsThree panels, one visible (hidden on the others). --gmcs-value at 25, 55 and 90, --gmcs-size: 170px, --gmcs-thickness: 17px, --gmcs-duration: 1.1s, one --gmcs-color per panel (#9aa63a, #d98a1c, #c5402a), dark text through --gmcs-text, aria-valuetext carrying the word. In the scene, a click outside the tabs moves to the next variety.
Share paid back for each item, line by line — cover table of a health insurer — Gauge Meter CSS example 2

② Share paid back for each item, line by line — cover table of a health insurer

WhenThe cover table lists five items: glasses, dental, hearing aids… Each line unfolds; inside, a small gauge shows the share paid back (85% for a hearing aid) next to a worked example in euros.
WhyA reimbursement percentage is abstract; an arc that is nearly full or half empty compares from line to line with no maths. The gauge stays a detail in the line, the text carries the amounts.
SettingsFive details elements sharing one name attribute (only one open at a time). --gmcs-size: 104px, --gmcs-thickness: 11px, --gmcs-duration: 1.2s, --gmcs-color: #12806f, the root's minimum height reset to 0 by a page rule. No page-side script. Inside a details, the gauge fills the first time the line is opened, not the following times.
Road salt in stock before winter — roads bulletin of a mountain village — Gauge Meter CSS example 3

③ Road salt in stock before winter — roads bulletin of a mountain village

WhenThe weekly bulletin opens on a large blue gauge: 72% of the silo, that is 216 tonnes out of 300. On the right, the state of the village's three roads and the date of the next delivery.
WhyThis is the figure residents come for: is there enough left to grit? A gauge between “empty silo” and “300 t” answers before a single line is read, and as the bulletin is a page written by the town hall, a value set in the HTML is all it takes.
Settings--gmcs-value: 72, --gmcs-size: 250px, --gmcs-thickness: 26px, --gmcs-duration: 1.6s, --gmcs-color: #1f5fae, track #cfdbea, transparent background. The “empty silo” and “300 t” markers are printed by the page under the gauge. In the scene, the fill is replayed on the first pointer movement.

How it works

Three elements inside a .gmcs-gauge box: a track, an arc, a text. Track and arc are two hollow discs drawn with border and border-radius: 50%. The box, twice as wide as it is tall, clips whatever sticks out: only the upper half is seen.

The arc is coloured on two borders only, top and left: that makes half a ring. Rotated by −135° it is fully hidden below the box. The value goes in the gauge's style attribute, --gmcs-value: 70, and every point turns the arc by 1.8°: at 50 it covers the left half, at 100 the whole half-circle.

The fill is a 1.5 s CSS animation starting from the hidden position. It plays once per display: inside a tab hidden with hidden or display: none, the gauge fills again each time the tab comes back. The few lines of script provided compute nothing: they keep the animation paused until half of the gauge is on screen.

The text in the middle is yours: “70%”, “Bold”, “216 t”. Its size follows the diameter (16% of --gmcs-size). Nothing ties it to the value: when you change --gmcs-value, change it too, along with aria-valuenow.

Accessibility

  • Role and name: the gauge is a role="meter"; Chromium exposes it as “Level: 70%” (the name comes from aria-label, to be replaced). If the centre shows a word instead of a number, add aria-valuetext with that word.
  • Two values to keep in step: the arc reads --gmcs-value, assistive technology reads aria-valuenow. The code does not check that they agree.
  • “Less animation” preference: the arc is shown at its final angle straight away.
  • Interaction: none. The gauge informs; it cannot be adjusted by mouse, finger or keyboard.
  • Colour alone does not say “good” or “bad”: if you turn the arc red above a threshold, keep a word or a figure next to it.

Browser compatibility

Borders, a transform: rotate() computed with calc() and a custom property, @keyframes, clamp() to bound the value; IntersectionObserver for the optional script. Angles recorded in Chromium 149, Firefox 151 and WebKit 26.5: −135° at 0, −45° at 50, +45° at 100; 130 is brought back to +45° and −20 to −135°. The text stays inside the hollow of the ring from 60 to 220 px in diameter.

Chrome 79+✓ Full (measured)
Firefox 75+✓ Full (measured)
Safari 13.1+✓ WebKit engine measured, real Safari not checked
Edge 79+✓ Full (Chromium engine)
Safari iOS 13.4+✓ Not checked on a phone
Chrome Android 79+✓ Full (Chromium engine)

Before these versions clamp() is ignored: the gauge works, but a value outside 0 to 100 draws a wrong arc. Without JavaScript, or without IntersectionObserver, the fill starts as soon as the page loads, even if the gauge sits further down.

The code

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

index.html — structure
<div class="fx-0237-root">
  <div class="gmcs-gauge" role="meter" aria-label="Level" aria-valuemin="0" aria-valuemax="100" aria-valuenow="70" style="--gmcs-value: 70">
    <div class="gmcs-track"></div>
    <div class="gmcs-fill"></div>
    <span class="gmcs-text">70%</span>
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
--gmcs-value in the style of .gmcs-gauge (HTML) 70 Level of the arc, 0 to 100. Outside those bounds the value is brought back to 0 or 100. Changed after display, it makes the arc jump with no transition.
aria-valuenow and the text of .gmcs-text (HTML) 70 and “70%” What assistive technology reads and what shows in the middle. You write both, in line with the value.
--gmcs-color, --gmcs-track (CSS) #6366f1, 20% indigo Tint of the arc and of the track behind it.
--gmcs-text (CSS) #fff Colour of the central text; darken it on a light page.
--gmcs-size (CSS) 150px Width of the gauge; its height is half of it and the text follows.
--gmcs-thickness (CSS) 15px Thickness of the ring. It does not follow the diameter: allow roughly a tenth of --gmcs-size.
--gmcs-duration (CSS) 1.5s Fill time.
--gmcs-bg and the root's min-height (CSS) #0a0a0f, 300px Background of the block and height reserved around the gauge. Inside a component: --gmcs-bg: transparent and a .fx-0237-root { min-height: 0 } rule.

FAQ

Gauge Meter is an SVG gauge with a needle and a green, yellow, red gradient; a script drives it and it glides to every new value. This one is pure CSS: no needle, one colour, a value written in the HTML, and it shows without JavaScript. For a figure that moves while the page is open, take the other one; for a value known when the page is produced, this one is enough and weighs less.
No, not with this code. The motion is an entrance animation: a change of --gmcs-value applies at once. Adding a transition on .gmcs-fill is no reliable fix: we tried, the arc glides in WebKit but still jumps in Chromium and Firefox. To show a new value with motion, hide the gauge and show it again: it restarts from zero. If the value changes often, the twin effect is built for that.
With the script provided, no: it pauses the animation and only releases it once half of the gauge is visible. Without it, the fill plays on load, out of sight. Either way the final state is the same.