Meter
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 linear gauge bar with pattern fills to differentiate zones.
Import
import { Meter } from "~lib/data-display/meter";
Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | number | Yes | N/A | Current value |
min | number | No | 0 | Minimum value |
max | number | No | 100 | Maximum value |
zones | { end: number; pattern: PatternType; label?: string }[] | No | N/A | Zone segments |
labels | "auto" | "all" | "active" | "none" | No | "auto" | Which zone labels to show under the bar |
label | string | No | N/A | Label above meter |
labelSize | "xs" | "sm" | "base" | No | "xs" | Size of the label, value and end labels |
caption | ReactNode | No | N/A | Content shown above the meter in place of the label |
showValue | boolean | No | true | Show numeric value |
showCategory | boolean | No | false | Show the label of the zone the value falls in, instead of the number |
format | (value: number) => string | No | N/A | Writes the numbers the meter prints, such as a price with its currency |
ends | "none" | "values" | { min: string; max: string } | No | "none" | What to print under the two ends of the bar |
marker | IconName | ReactElement | No | N/A | An Icon or a small node drawn on the bar in place of the triangle |
markerBearing | number | No | N/A | Degrees clockwise to turn an icon marker, for the way it faces |
width | number | string | No | 200 | Width in px, or a CSS width such as "100%" |