Skip to main content

Gauge

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A semicircular gauge with a needle that displays a value within a range, optionally divided into patterned zones.

Import​

import { Gauge } from "~lib/data-display/gauge";

Props​

NameTypeRequiredDefaultDescription
valuenumberYesN/ACurrent value to display
minnumberNo0Minimum scale value
maxnumberNo100Maximum scale value
labelstringNoN/ALabel shown below the value
showValuebooleanNotrueWhether to render the numeric value
unitstringNoN/AUnit set smaller after the value, such as "°C"
zones{ end: number; pattern: PatternType; label?: string }[]NoN/AQualitative arc zones, each labelled outside the arc when it has a label
widthnumber | stringNo100%Container width
heightnumber | stringNo100%Container height

Examples​

Simple​

Open Simple in Storybook

With a Unit​

Add a unit to set it smaller after the value, and keep label for the name of what is measured.

Open With Unit in Storybook

With Zones​

Open With Zones in Storybook

Labelled Bands​

Give each zone a label to name it around the outside of the arc. For a scale of whole-number bands, such as an air quality index from 1 to 5, set min and max half a step beyond the ends so each value lands in the middle of its band.

Open Air Quality Bands in Storybook
Open Zone Labels Without Label in Storybook

No Value​

Open No Value in Storybook

Custom Range​

Open Custom Range in Storybook

Negative Range​

Open Negative Range in Storybook

Single Zone​

Open Single Zone in Storybook

At Minimum​

Open At Minimum in Storybook

See Also​