Skip to the content

InputRange

InputRange is a slider for one number between min and max, operated by mouse, touch and keyboard. The thumb is an ARIA slider, so it always needs a name: a visible label, or aria-label / aria-labelledby.
Forms

When to use

Use when
  • The user sets a value by feel within a known range: price filter, volume.
  • The value is an ordered scale of a few named steps (low → max).
Avoid when
  • The exact number matters (age, quantity) — use Input with type="number".
  • The options have no order — use Radio or Option.

Usage

50
<InputRange aria-label="Price" min={0} max={200} value={price} onChange={setPrice} />

Defaults are min={0}, max={100}, step={1}, value={50}. Both events receive the number. onInput fires on every step change; onChange is the committed value, debounced 100 ms while dragging and immediate on a key press. Neither fires when the value does not change.

Stepped scale

mark draws a dot per step; markLabel prints getLabelValue(n) under each, bolding the picked one. label adds a header row that names the slider, and showValue prints the value at its end instead of the floating bubble.

Alignmentstd
const LEVELS = ['lenient', 'conv', 'std', 'strict', 'crit'];

<InputRange
  label="Alignment"
  showValue
  mark
  markLabel
  max={4}
  value={level}
  getLabelValue={(n) => LEVELS[n]}
  onChange={setLevel}
/>;

Gradient

gradient paints the track from the feedback tokens (danger → warning → success), so themes and presets retint it. gradient="descending" reverses it for metrics where lower is better. Skip it for scales with no good end.

25%
<InputRange aria-label="Risk" gradient="descending" mark markLabel step={25} getLabelValue={(n) => `${n}%`} />

Inside a Field

Field names the slider with aria-labelledby pointing at its label. For the header row instead, set hideLabel on the Field and pass label in inputProps.

<Field
  component={InputRange}
  name="effort"
  label="Effort"
  inputProps={{ mark: true, markLabel: true, min: 0, max: 3, getLabelValue }}
/>

Accessibility

  • The thumb has aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext from getLabelValue.
  • ←/↓ and →/↑ move one step; PageDown/PageUp move a tenth of the range; Home/End jump to the ends.
  • It is one tab stop with a :focus-visible outline; a press on the track moves the thumb there and focuses it.
  • Under a coarse pointer the thumb grows and the bubble sits higher, clear of the finger.

Properties

See also