Gauge
Included in RC.12
Available in Mavis 0.1.0-rc.12 for Vue + Vite, Nuxt and NativeScript. Keep the Mavis packages at the same version.
<MGauge :value="balance" label="Weekly balance" suffix="%" semi animateNumber />| Prop | Type | Default | Contract |
|---|---|---|---|
value / min / max | number | required / 0 / 100 | Finite range; value is clamped for visual and semantic output. |
semi | boolean | false | Use a half circle instead of a full ring. |
size / strokeWidth | number | 220 / 7 | Size >= 80 px/DIP; stroke width in viewBox units, (0,18]. |
animated / animateNumber | boolean | true / false | Jolt arc interpolation; optional NumberFlow presentation. |
color / suffix / formatValue | string / string / function | theme / empty / default | Color, suffix and canonical value formatting. |
zones | readonly GaugeZone[] | [] | Up to six increasing { from, tone, label? } bands; tone is success, warning or danger. |
The meter exposes its final value immediately while Jolt animates strokeEnd. The shared shape backend paints native arcs and Web SVG; server HTML includes a static SVG fallback. A textual value remains available independently of the decorative drawing. This component measures a value; use Progress for task completion.
Zones
<MGauge
:value="load"
label="Studio load"
suffix="%"
:zones="[
{ from: 50, tone: 'success', label: 'Balanced' },
{ from: 80, tone: 'warning', label: 'Stretched' },
{ from: 95, tone: 'danger', label: 'Overbooked' },
]"
/>Each zone runs from from to the next zone or to max, and is tinted on the track. Inside a zone the arc takes the zone's color and its label joins the spoken value (98% · Overbooked), so the meaning never rests on color alone. Below the first zone the arc keeps color.
Motion
The first time the gauge is on screen, the arc sweeps up to the reading. Later changes overshoot a little and settle with the theme's spring, so a calm theme stays calm. Climbing into a more serious zone plays one short moment: a bump for warning, a shake and a light haptic for danger. Going back down, or moving within a zone, does not. The meter value changes immediately and the number only rolls with animateNumber. Under reduced motion the arc settles at once.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
const value = ref(72),
semi = ref(true),
animated = ref(true),
animateNumber = ref(true),
zoned = ref(true)
const zones = computed(() =>
zoned.value
? [
{ from: 50, tone: 'success' as const, label: t('Balanced', 'Equilibrado') },
{ from: 80, tone: 'warning' as const, label: t('Stretched', 'No limite') },
{ from: 95, tone: 'danger' as const, label: t('Overbooked', 'Sobrecarregado') },
]
: [],
)
</script>
<template>
<MColumn gap="lg"
><MText text="PULSE / A LITTLE PROGRESS" variant="overline" tone="primary" /><MCard
padding="lg"
gap="lg"
><MText
:text="t('Make space for what matters.', 'Abra espaço para o que importa.')"
variant="title" /><MGauge
id="balance-gauge"
:value="value"
:label="t('Weekly balance', 'Equilíbrio da semana')"
suffix="%"
:semi="semi"
:animated="animated"
:animateNumber="animateNumber"
:zones="zones" /><MSlider v-model="value" :label="t('Balance', 'Equilíbrio')" /><MRow
gap="sm"
wrap
><MButton
:text="t('Slow day', 'Dia tranquilo')"
variant="secondary"
@click="value = 24" /><MButton
:text="t('In the flow', 'No ritmo')"
variant="secondary"
@click="value = 68" /><MButton
:text="t('Say yes to everything', 'Dizer sim a tudo')"
@click="value = 98" /></MRow></MCard
><MRow gap="md" wrap
><MSwitch v-model="semi" :label="t('Half circle', 'Semicírculo')" /><MSwitch
v-model="animated"
:label="t('Animate arc', 'Animar arco')" /><MSwitch
v-model="animateNumber"
:label="t('Animate number', 'Animar número')" /><MSwitch
v-model="zoned"
:label="t('Show zones', 'Mostrar zonas')" /></MRow
></MColumn>
</template>Desktop
The track, the zones and the reading are native arcs in the colours of the theme, and the value with its zone label is read as one element. The arc does not sweep to a new value and a more serious zone plays no moment: the reading is drawn at once, and animateNumber has no effect; see Desktop components.