Passa al contenuto principale

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​

Apri 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.

Apri With Unit in Storybook

With Zones​

Apri 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.

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

No Value​

Apri No Value in Storybook

Custom Range​

Apri Custom Range in Storybook

Negative Range​

Apri Negative Range in Storybook

Single Zone​

Apri Single Zone in Storybook

At Minimum​

Apri At Minimum in Storybook

See Also​