DitherCharts

Meter

Updated

Meter is a gauge for a known range, like disk use or a score. It rates the value the way the native meter element does: solid ink in the optimum zone, a 50% dither in a suboptimum one and the danger color in a poor one, with notches under the bar at the thresholds. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

Disk used
API quota
Error budget burn
import "@/components/dithercharts/controls.css"
import { Meter } from "@/components/dithercharts/meter"

// Lower is better: under 60 is good, 60–85 fair, over 85 poor.
<Meter label="Disk used" value={72} max={100} low={60} high={85} optimum={0} valueText="72 of 100 GB" />

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add meter

Props

It renders a native element, so every other attribute that element takes passes through.

Meter props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the bar, and the meter's accessible name.
valuerequiredType numberDefault –The measurement, from min to max.
minType numberDefault 0
maxType numberDefault 100
lowType numberDefault `min`Values below this are in the low zone.
highType numberDefault `max`Values above this are in the high zone.
optimumType numberDefault halfway between `min` and `max`The best value, which says which zone is good.
valueTextType stringDefault –Shown beside the label instead of the percentage, and read by screen readers, e.g. "72 of 100 GB".
showValueType booleanDefault trueShows the value beside the label.
classNameType stringDefault –