Zum Hauptinhalt springen

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​

Simple in Storybook öffnen

With a Unit​

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

With Unit in Storybook öffnen

With Zones​

With Zones in Storybook öffnen

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.

Air Quality Bands in Storybook öffnen
Zone Labels Without Label in Storybook öffnen

No Value​

No Value in Storybook öffnen

Custom Range​

Custom Range in Storybook öffnen

Negative Range​

Negative Range in Storybook öffnen

Single Zone​

Single Zone in Storybook öffnen

At Minimum​

At Minimum in Storybook öffnen

See Also​