Gauge
An open arc that fills to value out of max, with the reading in its center. When the value changes, the arc sweeps and the number counts to it together.
Installation
Copy the command below and run it in your terminal.
Usage
value is required; max defaults to 100, size to md, and tone to primary. Without label, screen readers announce the meter
as "72 of 100", so pass a label that says what it measures.
Gauge.Root on its own renders Track, Indicator, and Value. Compose the parts yourself to
restyle or leave one out. Gauge.Value shows the whole percent by default; its children
snippet receives the animated value, max, and percent. The percent reads 0 or 100 only
at the bounds.
Examples
Live updates
Changes sweep over --motion-duration-gauge (480ms by default) and snap when reduced motion is on. Switch tone at your own
thresholds to warn as the limit gets close.
Sizes
sm is 20px, md is 32px, and lg is 56px. Root leaves Value out at sm, where the number would be too small to read.
Context window
At sm, put the reading in text beside the gauge.
Usage limit
Set max to the limit and format the center with the Value snippet.
Anatomy
Gauge.Root - Sets the value, max, tone, and size of the meter.
Gauge.Track - Draws the full arc behind the reading.
Gauge.Indicator - Fills the arc up to the value.
Gauge.Value - Shows the reading in the center of the arc.
<script lang="ts"> import * as Gauge from '@sivir-ui/svelte/components/gauge'; </script> <Gauge.Root value={58} label="Context used" />