UI

Range

A unified range control supporting standard, elastic, histogram, window, and lens layouts.

import { RangeInput } from '@uthereal/ui/range-input'

Range input playground

Minimum price
Maximum price
Loading interactive preview…

Overview

RangeInput unifies five range selection archetypes behind one schema, shared numeric math, and consistent field anatomy. Use layout to pick the interaction model that fits your scale. All five layouts share min, max, step, largeStep, marks, valueFormat, unit, and onValueChange / onValueCommit.

LayoutThumbsRequired dataRole of marksBest for
standard1 or 2NoneTrack ticks and labelsGeneral single values, two-thumb ranges, and vertical scales.
elastic1NoneTactile magnetic detentsTactile settings with rubber-band ends and swaying value tag.
histogram2Sample arrayUnusedFiltering numeric distributions such as prices or durations.
window2 + panTime seriesAxis tick labelsSelecting and panning a time window over an area chart.
lens2NoneMagnetic dock presetsFine scales with benchmark stops and fusing value bubbles.

Use RangeInput when approximate position or data shape guides the choice. When the user must type an exact number, use Number. For a single value on a scrolling tape measure, use Measurement.

Usage

'use client'
import { useState } from 'react'
import { RangeInput } from '@uthereal/ui/range-input'

export function PriceFilter() {
  const [range, setRange] = useState([20, 80])
  return (
    <RangeInput
      label="Price"
      thumbLabels={['Minimum price', 'Maximum price']}
      valueFormat={{
        style: 'currency',
        currency: 'USD',
        maximumFractionDigits: 0,
      }}
      value={range}
      onValueChange={setRange}
      onValueCommit={(next) => console.log('commit', next)}
    />
  )
}

onValueChange emits a canonical number[] on every movement. onValueCommit runs once a drag, flick coast, or keyboard action settles.

Examples

Elastic

Set layout="elastic" for a single-thumb track that stretches past either limit and pushes startIcon and endIcon outward. marks act as tactile magnetic detents with tick feedback, and a trailing value tag tilts with thumb speed.

Histogram

Set layout="histogram" with raw sample numbers in data. Bars inside the selected range light up on the exact same frame as the track fill, and released thumbs settle onto bar edges when snapToBins is enabled.

Nightly rate

Window

Set layout="window" with an evenly-spaced time series in data. Drag either handle to resize, drag or flick inside the frame to pan with momentum, and enable live to pulse a dot on the latest point.

Request volume

Lens

Set layout="lens" for a fine scale that magnifies ticks under each thumb like a dock. marks act as magnetic presets reachable by pointer or keyboard, and value bubbles fuse into one pill when the thumbs meet.

Salary band

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Range"Visible label and accessible name of the group or thumbs, e.g. "Price" or "Report dates".
hideLabelbooleanDefault: falseHide the label visually when the context already names the field. It is still announced.
descriptionstring—Supporting text below the field, announced with it. Use it for format hints and constraints.
errorstring—Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely.
readOnlybooleanDefault: falseThe value can be focused, selected, and copied, but not edited. It is still submitted with a form.
disabledbooleanDefault: falseUnavailable and removed from the tab order. A disabled field is not submitted with a form.
namestring—Native form field name, submitted with the value in a form.
layout'standard' | 'elastic' | 'histogram' | 'window' | 'lens'Default: "standard"Interaction archetype: standard (single or dual slider), elastic (single-thumb rubber-band track with swaying tag), histogram (dual range over a bar distribution), window (resizable, flick-to-pan window over an area chart), or lens (fisheye magnifying ticks with fusing value bubbles).
minnumber—Lowest value on the scale. Defaults to 0, or the smallest value in data for histogram.
maxnumber—Highest value on the scale. Defaults to 100, the largest data value in histogram, or data.length - 1 in window.
stepnumberDefault: 1Smallest increment. Arrow keys move one step.
largeStepnumber—Increment for Page Up, Page Down, and Shift+arrow. Omit for a tenth of the span, or the next bar edge in histogram.
defaultValuenumber | [number, number]—Initial value: a single number (or [v]) for one thumb, or [min, max] for a range. Omit to use the layout default.
minStepsBetweenThumbsintegerDefault: 0Closest two thumbs may sit, in steps. Also defines the minimum window width in window layout.
maxSpannumber—Widest allowed range (end minus start) in domain units. Omit to allow the full span.
marksRangeMark[]—Scale stops: track marks in standard, tactile snap detents in elastic, axis ticks in window, and magnetic dock presets in lens.
datanumber[]—Numeric array required by histogram (raw samples bucketed into bins) and window (evenly-spaced time series).
binsintegerDefault: 32Number of histogram bars (4 to 60, default 32). Used in histogram layout.
snapToBinsbooleanDefault: trueIn histogram layout, released thumbs near a bar edge settle onto that bar boundary.
chartHeightinteger—Chart height in px (48 to 240). Defaults to 76 in histogram and 112 in window.
livebooleanDefault: falseIn window layout, pulses a live dot on the latest data point.
magnetnumberDefault: 16In lens layout, pixel reach of magnetic preset detents (0 disables detents, default 16).
showValuebooleanDefault: trueShow the formatted readout (header readout, window start/span/end row, or fusing lens bubbles).
valueFormatNumberFormat—Intl display format: style decimal, percent (0.25 shows 25%), or currency, plus fraction digits.
unitstring—Short unit suffix appended after formatted numbers, e.g. "dB", "px", or "days".
thumbLabels[string, string]—Accessible names of a two-thumb range, e.g. ["Minimum price", "Maximum price"]. Defaults to "{label}, minimum" and "{label}, maximum".
startIconplus | minus | x | check | pencil | trash-2 | copy | download | upload | share-2 | external-link | link | refresh-cw | rotate-ccw | search | filter | settings | ellipsis | ellipsis-vertical | eye | eye-off | lock | log-out | send | square | paperclip | mic | star | chevron-down | chevron-up | chevron-left | chevron-right | chevrons-up-down | arrow-left | arrow-right | arrow-up | arrow-down | menu | panel-left | maximize-2 | minimize-2 | file | file-text | folder | image | table | book-open | globe | calendar | code | message-square | sparkles | bot | user | brain | wrench | terminal | thumbs-up | thumbs-down | list-checks | info | circle-check | triangle-alert | circle-x | circle-help | clock | circle | circle-dashed | bell | loader-circle | mail | phone | chevrons-down-up | pipette | hash | bookmark | headphones | video | presentation | archive | circle-alert | sun | moon | monitor | command | folder-open | play | pause | file-image | file-play | file-archive | message-circle | check-check | circle-dot | smile-plus | corner-down-right | rotate-cw | file-code-corner | copy-plus | pin | git-pull-request | git-merge | git-pull-request-closed | file-diff | sun-moon | user-round | credit-card | calendar-days | signal-high | camera | image-plus | heart | bell-off—Curated icon before the track in standard and elastic layouts. Pushes outward during overpull in elastic.
endIconplus | minus | x | check | pencil | trash-2 | copy | download | upload | share-2 | external-link | link | refresh-cw | rotate-ccw | search | filter | settings | ellipsis | ellipsis-vertical | eye | eye-off | lock | log-out | send | square | paperclip | mic | star | chevron-down | chevron-up | chevron-left | chevron-right | chevrons-up-down | arrow-left | arrow-right | arrow-up | arrow-down | menu | panel-left | maximize-2 | minimize-2 | file | file-text | folder | image | table | book-open | globe | calendar | code | message-square | sparkles | bot | user | brain | wrench | terminal | thumbs-up | thumbs-down | list-checks | info | circle-check | triangle-alert | circle-x | circle-help | clock | circle | circle-dashed | bell | loader-circle | mail | phone | chevrons-down-up | pipette | hash | bookmark | headphones | video | presentation | archive | circle-alert | sun | moon | monitor | command | folder-open | play | pause | file-image | file-play | file-archive | message-circle | check-check | circle-dot | smile-plus | corner-down-right | rotate-cw | file-code-corner | copy-plus | pin | git-pull-request | git-merge | git-pull-request-closed | file-diff | sun-moon | user-round | credit-card | calendar-days | signal-high | camera | image-plus | heart | bell-off—Curated icon after the track in standard and elastic layouts. Pushes outward during overpull in elastic.
orientationhorizontal | verticalDefault: "horizontal"Horizontal (default) or vertical. Vertical orientation is supported in standard layout.
sizesm | md | lgDefault: "md"Thumb, track, and text size: sm, md, or lg.
recipestudio | softDefault: "studio"Visual treatment. Both studio and soft share identical interaction behavior.
themeRangeInputTheme—Color mode, accent, and semantic tokens, plus thumbSize, trackThickness, length, and chartHeight.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. None and system reduced motion jump directly without coasting, rubber-banding, or pulse.
motionOptionsRangeInputMotionOptions—transition: how thumbs and fills spring to a new value (Arc snappy spring by default). Durations are milliseconds.
dirltr | rtl—Reading direction. Omit to inherit the page direction.
localestring—BCP 47 locale for separators and currency symbols, e.g. en-US or de-CH. Omit to inherit the application locale.

React integration

PropPurpose
value, onValueChangeControlled value (number or readonly number[]) and canonical number[] hook.
onValueCommit(value)Fires once a drag, flick coast, preset click, or key action settles.
formatValue(value)Custom value formatter; overrides valueFormat and unit.
formatSpan(span) | nullFormats the middle span readout in window layout; pass null to hide it.
start, endCustom leading or trailing slots for standard and elastic (override icons).
refThe field root element.
presetApplication defaults, overridden by explicit instance props.
tokensCSS variables applied after the typed theme.
className, styleAdded to the field root element.
Native attributesid (first slider control id), aria-describedby, data-*.

Keyboard & accessibility

KeyInteraction
TabMoves through each role="slider" thumb (plus window body in window, presets in lens).
Arrow keysMove one step (direction follows dir on standard, elastic, histogram, and lens; window stays chronological left-to-right).
Shift + arrow, PageUp, PageDownMove largeStep (or the next bar edge in histogram).
Home, EndJump to the slider's minimum or maximum allowed bound.
Enter, Space (on lens preset)Move the nearest thumb onto that preset.

Every thumb and window handle exposes role="slider" with aria-valuemin, aria-valuemax, aria-valuenow, and formatted aria-valuetext. Thumbs never cross and respect minStepsBetweenThumbs and maxSpan. Pointer focus stays quiet until keyboard navigation begins. All layouts support forced-colors: active and submit hidden form inputs when name is set.

Motion and theming

All pointer drags, overpull stretches, fisheye tick displacements, and area clips update through motion values or 240 Hz requestAnimationFrame loops that pause when idle, offscreen, or in background tabs.

  • standard and elastic rubber-band past limits and spring onto the step grid or magnetic detents.
  • histogram syncs bar illumination and track fill through one shared clip path and shows a hairline guide while dragging.
  • window projects pan flicks into a critically damped coast and morphs area paths when data updates.
  • lens spreads and swells nearby ticks with a Gaussian fisheye and springs bubble widths and fusion bridges.
  • motion="none" and prefers-reduced-motion: reduce disable rubber-banding, coasting, trailing, chart morphs, and the live dot pulse while keeping full pointer, keyboard, and detent behavior.

theme accepts the core, control, and selectionControl token groups, plus shadowRaised, borderStrong, series1, and component tokens thumbSize, trackThickness, length, and chartHeight.

Composition

RangeInput is a leaf component. Its canonical number[] value is host state at /fields/instance-<id>/value. Stored values remain intact while they fit the layout's thumb count, domain bounds, and span limits.

{
  "type": "RangeInput",
  "props": {
    "label": "Salary band",
    "layout": "lens",
    "min": 40000,
    "max": 160000,
    "step": 1000,
    "defaultValue": [74000, 96000],
    "marks": [
      { "value": 62000, "label": "Entry" },
      { "value": 82000, "label": "Median" },
      { "value": 104000, "label": "Top quarter" }
    ],
    "valueFormat": {
      "style": "currency",
      "currency": "USD",
      "maximumFractionDigits": 0
    }
  },
  "children": []
}

On this page