Inspector Meter

Contrast5.30:1
About this component

Inspector Meter

The row that reports rather than asks: a measurement the work produced, shown in the family's surface so it can sit among the settings that caused it. Threshold bands colour the bar and the number without the caller recomputing them, and it is a meter rather than a progress bar, which is how it is announced.

Usage

The import and the props worth knowing about, in one place.

import { InspectorMeter } from "@/components/beste/component/inspector-meter";

// Bands read lowest first; the last one the value has reached wins
<InspectorMeter
  label="Contrast"
  value={ratio}
  min={1}
  max={21}
  precision={2}
  suffix=":1"
  thresholds={[
    { from: 1, status: "danger" },
    { from: 3, status: "warning" },
    { from: 4.5, status: "success" },
  ]}
/>

<InspectorMeter
  label="Bundle"
  value={bytes}
  max={250_000}
  format={(n) => `${Math.round(n / 1000)} kB`}   // decides the whole reading
  status="warning"                                  // overrides the bands outright
  tone="outline"                                    // "muted" (default) | "outline" | "ghost"
  size="sm"                                         // "sm" | "default" | "lg"
/>

// A reading with no meaningful range is better off as a number alone
<InspectorMeter label="Products" value={1533} showBar={false} />

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
label*string—Label rendered on the left, inside the row.
iconLucideIcon—Optional leading icon shown before the label.
value*number—The reading.
minnumber0 to 100The range it sits in, which is what the bar is a fraction of.
maxnumber—
format(value: number) => string—How the number reads. Given a function, it decides outright; otherwise the value is printed with `precision` decimals and `suffix` after it.
suffixstring—Printed after the number, e.g. `%`, `kB`, `:1`.
precisionnumber0Decimals the printed number keeps.
status"neutral" | "success" | "warning" | "danger"—What the reading means. Left out, `thresholds` decides; with neither, the row is neutral.
thresholdsThreshold[]—Bands, lowest first. The last one whose `from` the value has reached wins, so a contrast ratio reads danger under 3, warning under 4.5 and success above it without the caller computing that on every render.
showBarbooleantrueShow the bar. A reading with no meaningful range — a file count, a word count — is better off as a number alone.
disabledboolean—Dim the row, for a reading that is not current.
tone"muted" | "outline" | "ghost""muted"Surface treatment: filled (default), hairline outline, or bare.
size"sm" | "default" | "lg""default"Row height preset.
classNamestring—
aria-labelstring—Accessible name. Falls back to `label`.

More Inspector components

View all Inspector