VisorVisor
ComponentsData Display

Meter

A thin meter for use against a limit, with a threshold tick, a hue and a one-line label.

Meter draws use against a limit: hours against a contract's ceiling, a month against its included hours. The track is the owner's hue tint, the used fill is that hue's ink, a tick marks the heads-up point, and a label sits under it. hue reads Paper's project hues, so switch the site theme to Paper (light or dark) to see the colours as designed. On other themes the meter falls back to neutrals.

Row meter

The compact size is one meter per row. Pass the heads-up point as a mark with threshold. Once value reaches it, the label's <strong> figure turns weight 800 in ink, never the alert colour (Client B below is past 80%).

83% of 54 h · heads-up sent
81% of 200 h · heads-up due
38% of 160 h
12.5 of 40 h covered this month

Contract meter

size="contract" is the full meter for one engagement. zones draw bands behind the fill (solid up to the low, hatched up to the high) and the pale track runs to the ceiling. Marks with a label and caption write text under their tick. hideWhenNarrow drops a mark's text under 30rem while keeping its tick, so a legend beside the meter still explains it.

160 hheads-up
166 hthe low
200 hceiling
118 h used of 200 h · 59% of the ceiling

Past the ceiling

Use past max is unresolved, so by default (overflow="alert") it stripes coral, the one alert case. The track stretches 6% past value to make room, and the fill stops at the limit.

160 hheads-up
166 hthe low
200 hceiling
212 h used of 200 h · 12 h past the ceiling, unresolved

Retainer months

A retainer's overage is billable, not a problem: overflow="ink" stripes it in ink and runs the fill through it. Give every month the same scale so the included-hours tick lines up.

September · 34 of 40 h · 6 h left
October · 46 of 40 h · +6 h overage
November · 12.5 of 40 h · 27.5 h left

Colour

hue takes a Paper project-hue angle (75, 99, 123 … 339) and sets three variables on the meter: --meter-hue-fill (the contract track), --meter-hue-fill-strong (the row track and the zones) and --meter-hue-ink (the fill). For a colour that is not a Paper hue, leave hue off and set them yourself:

<Meter value={30} max={40} style={{ '--meter-hue-fill': '…', '--meter-hue-fill-strong': '…', '--meter-hue-ink': '…' } as React.CSSProperties} />

--meter-tick, --meter-alert and --meter-hatch-width override the tick colour, the overflow colour and the stripe width. Every part carries a data-slot (meter-track, meter-fill, meter-zone, meter-overflow, meter-tick, meter-marks, meter-label) for anything else, such as dimming the fill of an ended contract.

Installation

npx visor add meter

This copies two files into your project:

  • components/ui/meter/meter.tsx — the component
  • components/ui/meter/meter.module.css — the styles

API Reference

MeterProps

PropTypeDefaultDescription
value*number—What has been used.
max*number—The limit: a contract's ceiling, a month's included hours.
marks{ value: number; label?: ReactNode; caption?: ReactNode; align?: 'start' | 'center' | 'end'; variant?: 'tick' | 'limit'; threshold?: boolean; hideWhenNarrow?: boolean }[][]Ticks on the track. `threshold` is the heads-up point: once `value` reaches it the label figure turns weight 800. `label` and `caption` draw text under the tick; `hideWhenNarrow` hides that text under 30rem (the tick stays). `variant="limit"` draws a 3px ceiling.
zones{ from?: number; to: number; variant?: 'solid' | 'hatched' }[][]Bands behind the fill in the hue's strong fill, solid or hatched (up to the low, then hatched to the high).
huenumber—A Paper project-hue angle (75 to 339). Reads `--paper-hue-<angle>-fill`, `-fill-strong` and `-ink`. For any other colour set `--meter-hue-fill`, `--meter-hue-fill-strong` and `--meter-hue-ink` yourself.
size"compact" | "contract""compact"`compact` is the 10px row meter; `contract` is the 30px meter with a thinner used bar.
overflow"alert" | "ink""alert"How use past `max` draws: `alert` stripes it coral (unresolved hours), `ink` stripes it in ink (billable overage) and runs the fill through it.
scalenumber—The value at the track's right edge. Defaults to `max`, or 6% past `value` when it overflows. Pass one scale to line several meters up.
childrenReactNode—The one-line label under the meter. Wrap the figure in `<strong>`; it names the meter for assistive tech.

Meter renders a <div> and accepts all standard div attributes.

Accessibility

  • The track has role="meter" with aria-valuemin, aria-valuemax and aria-valuenow. Its name comes from the label slot, or from aria-label when there is no label.
  • aria-valuenow never exceeds aria-valuemax; say how far past the limit the use went in the label ("12 h past the ceiling").
  • Ticks, zones and stripes are decoration inside the meter. Mark text is ordinary text.
  • Past the threshold the label changes weight, not only colour, and the overflow stripes have a pattern as well as a colour (WCAG 1.4.1).
  • The label is 13px on Paper in the secondary text colour, which meets AA on the page and card surfaces.