Gauge
Shows one reading on a 270- or 180-degree arc, colored by the same thresholds as Meter.
<arc-gauge>Overview
Gauge is the radial version of Meter: the same value, range and thresholds, drawn as an arc instead of a bar. A neutral track carries a value arc in the zone color with a matching glow, and the reading is in the middle in mono type, with an optional unit and a label under it. variant="full", the default, is a 270-degree horseshoe with the reading inside. variant="half" is a 180-degree semicircle with the reading on the baseline.
The colors follow the HTML <meter> rules, with Meter's low, high and optimum. When the optimum is in the high segment, as for battery level, values above high are green (success), values between low and high yellow (warning), and values below low red (error). When the optimum is in the low segment, as for an error rate, it's the other way round. With no thresholds, the range splits into thirds.
mode changes the coloring. zones is the default described above. plain draws one color, --gauge-fill (the accent by default), for a quantity that's neither good nor bad. diverging draws from center toward the value, in --gauge-below on one side and --gauge-above on the other, for a lean either way, such as -1 to +1. center defaults to halfway between min and max.
The arc sweeps in on first paint and again on every change. It uses role="meter" with aria-valuenow, aria-valuemin and aria-valuemax, and with a unit set, aria-valuetext gives the reading with its unit, so screen readers say "72%" and not a bare number.
Guidelines
Do
- Use it for a single reading that should stand out on a dashboard, such as CPU load, battery or a health score
- Set `low`, `high` and `optimum` to match what your numbers mean, as you would on Meter
- Set a `label`. It's shown under the reading and is the accessible name
- Set `unit` when the number alone is ambiguous: "72" means different things as %, ms or GB
- Use the `half` variant when vertical space is tight, as in a stat row or a card header
Don't
- Don't use it in dense layouts or lists of readings. Meter shows the same data in a fraction of the height
- Don't use it for a number with no meaningful range. Use Stat
- Don't use it for task progress. Use Progress
- Don't set `min` equal to or greater than `max`. The arc renders empty
- Don't rely on color alone for the zone. Keep the value and label visible, or add text beside it
Features
- `value` is clamped between `min` and `max`
- `no-value` hides the reading in the middle
- A custom color's glow reads the matching `-rgb` property, such as `--gauge-fill-rgb`
Preview
Usage
<arc-gauge
label="CPU Load"
value="72"
unit="%"
min="0"
max="100"
low="50"
high="80"
optimum="0"
></arc-gauge>import { Gauge } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Gauge
label="CPU Load"
value={72}
unit="%"
min={0}
max={100}
low={50}
high={80}
optimum={0}
/>
);
}<script setup>
import { Gauge } from '@arclux/arc-ui-vue';
</script>
<template>
<Gauge
label="CPU Load"
:value="72"
unit="%"
:min="0"
:max="100"
:low="50"
:high="80"
:optimum="0"
/>
</template><script>
import { Gauge } from '@arclux/arc-ui-svelte';
</script>
<Gauge
label="CPU Load"
value={72}
unit="%"
min={0}
max={100}
low={50}
high={80}
optimum={0}
/>import { Component } from '@angular/core';
import { Gauge } from '@arclux/arc-ui-angular';
@Component({
imports: [Gauge],
template: `
<arc-gauge
label="CPU Load"
[value]="72"
unit="%"
[min]="0"
[max]="100"
[low]="50"
[high]="80"
[optimum]="0"
></arc-gauge>
`,
})
export class MyComponent {}import { Gauge } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Gauge
label="CPU Load"
value={72}
unit="%"
min={0}
max={100}
low={50}
high={80}
optimum={0}
/>
);
}import { Gauge } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Gauge
label="CPU Load"
value={72}
unit="%"
min={0}
max={100}
low={50}
high={80}
optimum={0}
/>
);
}API
labelstring''- Label text displayed beneath the value and used as the accessible name.
unitstring''- Unit suffix rendered after the value (e.g. "%", "ms", "GB").
valuenumber0- Current gauge value. Clamped between
minandmax. Reflected as an attribute. minnumber0- Minimum value representing the empty end of the arc.
maxnumber100- Maximum value representing the full end of the arc.
lownumber0- Threshold below which the value is considered low. Used for color zone calculation.
highnumber0- Threshold above which the value is considered high. Used for color zone calculation.
optimumnumber0- The optimal value. Determines which end of the range is "good" for color zone logic.
variant'full' | 'half''full'- Arc shape:
fullis a 270-degree horseshoe,halfa 180-degree semicircle. mode'zones' | 'plain' | 'diverging''zones'- How the arc is coloured.
zones(the default) colours by the low/high/optimum thresholds in status colours.plainis one colour,--gauge-fill(default the accent), for a quantity that is not good or bad.divergingdraws fromcentertoward the value,--gauge-belowon one side and--gauge-aboveon the other (default chart series 1 and 2), for a lean either way, such as −1 to +1. A custom colour's glow reads the matching-rgbproperty (--gauge-fill-rgband so on). centernumber0- The midpoint of a diverging gauge. Defaults to halfway between
minandmax. Ignored by the other modes. showValuebooleantrue- Whether to render the numeric value in the center of the arc. Defaults to true; disable via the
showValueproperty.