Officina UI
Components

RangeSlider

Controlled two-thumb slider for selecting a lower and upper bound within a range.

RangeSlider is a two-thumb slider for choosing a span — a min and a max — such as a price or date range filter. It is controlled: value is a [number, number] tuple and onValueChange returns the updated tuple. Tune the bounds with min, max, and step, keep the thumbs apart with minStepsBetweenThumbs, and format the visible numbers with formatValue.

Example

Preview
$25 – $75
import { RangeSlider } from '@officina/ui';
import { useState } from 'react';

function PriceFilter() {
  const [range, setRange] = useState<[number, number]>([20, 80]);
  return (
    <RangeSlider
      label="Price range"
      value={range}
      onValueChange={setRange}
      min={0}
      max={100}
      minStepsBetweenThumbs={1}
      formatValue={(n) => `$${n}`}
    />
  );
}

API

PropTypeDefaultDescription
onValueChange*(value: [number, number]) => void—Called with the new [start, end] tuple as either thumb moves.
value*[number, number]—Current [start, end] values.
disabledboolean—
formatValue(n: number) => string—Format thumb/value captions (e.g. add a unit or currency).
invalidboolean—Marks the field invalid for validation styling and `aria-invalid`.
labelstring—Visible label above the slider.
maxnumber100Upper bound of the track. Defaults to 100.
minnumber0Lower bound of the track. Defaults to 0.
minStepsBetweenThumbsnumber0Minimum number of steps to keep between the two thumbs.
namestring—Form field name, for native form submission / form libraries.
stepnumber1Step increment between values.

On this page