Gauge
Installation
npx @mielui/svelte add gaugeyarn dlx @mielui/svelte add gaugebunx @mielui/svelte add gaugeUsage
value and max set the filled portion; values are clamped between zero and max, which defaults to 100. Give every gauge a label: it is the accessible name, since the center only shows a number. Children replace that number. The default number rolls when the value changes; for custom center content, use the numberShuffle action on the numeric text.
The default diameter is 120px. Set size for compact toolbar meters; the arc and center text scale with it. strokeWidth sets the track thickness, which defaults to 9.75% of the diameter. animation reveals the arc on entry by default, live adds a continuous highlight, and none turns motion off. Reduced motion and themes without motion also turn it off.
<script lang="ts">
import { Gauge } from '@mielui/svelte/components/gauge';
</script>
<Gauge value={85} label="Context remaining" />
<Gauge value={72} label="Monthly API usage" tone="warning">72%</Gauge>Changing values
Add files to approach the storage limit, then clear them. The meter transitions from its current value and changes tone near capacity. The label keeps the units explicit for screen readers.
Loading and missing measurements
Set loading while a measurement is being fetched. Pass value={null} when no measurement is available; zero is still a valid value. Gauge keeps its size, draws the matching ring and center text, and announces the state.
<Gauge value={usage} loading={pending} label="Storage used in GB" />
<Gauge value={null} label="Storage used in GB" />Examples
Usage update
The arc, the number, and the tone follow the value when it changes.
Monthly API usage
72,000 of 100,000 requests
Compact and detailed
Context remaining
85% available
Usage limit
Storage
18 of 20 seats
Backup complete
Data and animation states
Compare ready, loading, unavailable, zero, and full measurements. Reveal plays the entry animation; Live highlights the arc continuously without changing its value; None turns motion off. The live highlight pauses offscreen, in hidden tabs, and with reduced motion. Loading and unavailable states keep the same footprint.
GB used of 100 GB
Labels
Built-in text is English. Pass a labels object to translate the accessible name Gauge builds while loading (loading), when there is no data (empty), and when there is no label (value). GaugeLabels types it; every key is optional and each one is a function.
<Gauge
value={72}
labels={{
loading: (name) => `Chargement de ${name ?? 'la mesure'}`,
value: (value, max) => `${value} sur ${max}`
}}
/>API reference
Gauge
Displays a value as a filled arc.
labelsGaugeLabelsOverrides the built-in text and accessible names. Every key is optional and English is the fallback.
valueRequirednumber | nullThe bounded quantity shown by the filled arc. Pass null when no measurement is available.
loadingbooleanShow a loading ring while the measurement is being fetched.
Default
falsemaxnumberValue that fills the gauge.
Default
100labelstringDescribes the quantity, such as "Context remaining" or "Monthly API usage".
sizenumberDiameter in pixels. Defaults to 120; use an explicit size for inline meters.
Default
120strokeWidthnumberTrack and arc thickness in pixels. Defaults to 9.75% of the diameter, with a 3px minimum.
animation"reveal" | "live" | "none"Reveal the arc, highlight it continuously, or disable animation.
Default
'reveal'toneGaugeToneColor of the fill.
Default
'primary'classstringClasses added to the element.
childrenSnippet<[]>Content rendered inside.
pnpm dlx @mielui/svelte add gauge