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.
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | Type ReactNode | Default – | The caption above the bar, and the meter's accessible name. |
| valuerequired | Type number | Default – | The measurement, from min to max. |
| min | Type number | Default 0 | |
| max | Type number | Default 100 | |
| low | Type number | Default `min` | Values below this are in the low zone. |
| high | Type number | Default `max` | Values above this are in the high zone. |
| optimum | Type number | Default halfway between `min` and `max` | The best value, which says which zone is good. |
| valueText | Type string | Default – | Shown beside the label instead of the percentage, and read by screen readers, e.g. "72 of 100 GB". |
| showValue | Type boolean | Default true | Shows the value beside the label. |
| className | Type string | Default – |

