Gauge
Radial gauge with a sprung needle, redline and digital readout.
Installs motion.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/gauge.jsonUsage
import { Gauge } from "@/components/ui/gauge"
<Gauge label="Speed" unit="km/h" value={88} max={260} ticks={13} />Examples
Zones
Printed bands for cold, normal and hot. The band holding the value lights up.
Live data
Feed it new values as often as you like; the needle springs to each one without re-rendering the dial.
Sizes and colors
Small dials print their legends larger so they stay readable. className can set any other width.
API reference
Accepts every div attribute; the ref points at the root, which has role="meter".
| Prop | Type | Default |
|---|---|---|
value | numberCurrent reading, clamped to min and max. | None |
min | numberStart of the scale. | 0 |
max | numberEnd of the scale. | 100 |
label | stringLegend printed on the dial. Also the accessible name unless aria-label is set. | None |
unit | stringPrinted under the readout and read after the value. | None |
ticks | numberNumbered intervals on the scale. Numerals shrink, then skip, to fit. | 10 |
redline | numberStart of the red zone. Past it the scale prints red and the arc burns red. | None |
zones | { from: number; to: number; color: NeonColor }[]Colored bands inside the scale. The band holding the value lights up. | None |
formatValue | (value: number) => stringFormats the readout and aria-valuetext. | None |
color | NeonColorPalette name or hex for the needle, arc and readout. | inherited |
size | "sm"160, 224 or 288px across. | "md" |
Accessibility
- The root has role="meter" with aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext (the formatted value and unit).
- The dial itself is hidden from screen readers; the meter's value is the single source of truth.
- The needle, arc and readout are driven by a spring outside React rendering. Under reduced motion they jump straight to the value.