Integrated ResearchPicasso
Components

Threshold slider

Two numbers that decide when a metric stops being fine — and the bands they create.

{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}

Two numbers that decide when a metric stops being fine — and the bands they create.

Import

import { ThresholdSlider } from "@ir/ui";

Watch out

  • The two Figma sets disagree on the thumb colour. The preset gallery binds status/warning and status/critical; the state set binds bg/warning/emphasis and bg/danger/emphasis, which are warning-500 and (in dark) danger-500 — different values. status/* wins here: it is the family that has a healthy member, it is what both sets use for the bands, and it makes each thumb the colour of the boundary it sits on, which is the whole point of the control.

Props

PropTypeRequiredWhat it does
warningnumberyesThe value at which the metric stops being healthy.
criticalnumberyesThe value at which it stops being merely worrying.
format(value: number) => stringHow a value is written — units, decimals. Defaults to String.

Do and don't

Put the thresholds in the order the metric means and let the bands follow.

Don't — Add a direction prop, or flip the bands by hand.

critical < warning is what "low is bad" means. A separate flag is a second source of truth that can disagree with the numbers, and the disagreement is invisible until someone is paged.

Keep the Critical and Warning labels above the thumbs.

Don't — Rely on the red, amber and green bands to say which is which.

The bands are three hues along one bar, which is the hardest case for anyone with a red-green deficiency. The label over each thumb is what survives; the colour reinforces it.

Bound each thumb by its twin, and say so with aria-valuemin and aria-valuemax.

Don't — Let one threshold pass the other, or clamp silently to the track ends.

Crossed thresholds invert the bands and mean nothing. A screen reader that is told the range is 0–100 when the real bound is 85 gives an answer the control will not honour. And when they do meet, the label that survives is the critical one: there is no warning band at the boundary, so crossing it skips warning entirely and the number is the critical limit.

Pass format so −80 reads as −80 dBm and 70 as 70%.

Don't — Show bare numbers and put the unit in the field label.

Thresholds get read out of context — in a summary, an alert, a screen reader. A number with no unit is a number someone has to go and look up.

Keep it for setting the two boundaries; show the live reading elsewhere.

Don't — Use it to report where a metric currently sits.

It is a configuration control. Putting the current value on the same bar makes the thing you are editing and the thing you are watching look like one control.

Accessibility

  • Two thumbs, each role="slider" with its own aria-label, aria-valuenow and an aria-valuetext that is the formatted value — "-80 dBm", not "-80".
  • Each thumb's aria-valuemin and aria-valuemax are bounded by its twin as well as by the track, so the announced range always matches what the thumb can actually do.
  • Disabled sets aria-disabled and tabIndex -1 but leaves the thumbs in the accessibility tree. A disabled control is still something you may need to read.
  • Arrow keys move by step, Page by ten steps, Home and End to the bounds.

Where it is drawn

Figma — structure from figma, measurements from figma.

Open in Storybook

On this page