Skip to content

Components

Slider

A range slider with a glass thumb: a small pill at rest that opens into a wide lens while you hold it.

Markdown
Latest changeNewv1.0.0First release, in @vitrumui/react/controls/range-slider.All changes →
range-slider.tsx
40

Use it for

  • Picking a value on a continuous range: volume, brightness, opacity.

Not for

  • Exact numbers the user must type: use a number input.
  • Confirming one action: that is Slide to Confirm.

Installation

npm install @vitrumui/react
Peer: React 19

Slider, Switch and Checkbox are drawn by their own renderer, which needs three. The install command adds it; the rest of the kit stays dependency-free.

Usage

app.tsx
import { RangeSlider } from '@vitrumui/react/controls/range-slider'

const [volume, setVolume] = useState(60)

<RangeSlider label="Volume" value={volume} onChange={setVolume} />

Drag the glass, or press the track to bring it there. While held, the pill swells into a clear lens that bends the track and the fill beneath it, and squashes and stretches with its speed; released, it springs back to the small pill.

Examples

Colours
range-slider-colors.tsx
30
45
60
75

color is the filled part of the track; without it the slider is the kit's blue. The thumb stays white at rest and clear glass while held.

API reference

PropTypeDefault
value

Current value.

number50
onChange

Called with the new value.

(value: number) => void—
min / max / step

The range and its step.

number0 / 100 / 1
label

Label above the track; an empty string hides it.

string'Volume'
showValue

Shows the value next to the label.

booleantrue
size

Track height 8, 12, 18 or 26 px; the glass scales with it.

'sm' | 'md' | 'lg' | 'xl''md'
startIcon / endIcon

Icons at either end of the track.

IconName | 'none''none'
color

The filled part of the track: a hex, rgb() or named colour, not a CSS variable.

string'#3291FF'
theme

Overrides the page theme for this slider.

'light' | 'dark'—
restFrost

The thumb at rest: 1 = a white pill, 0 = clear glass. Held, it is always clear glass.

number1
refraction

How far the lens bends what lies beneath.

number37
dispersion / rimIntensity / magnification

Colour fringing, rim light and zoom of the lens.

number0.12 / 0.55 / 0
motionStretch / motionSmoothing

Squash and stretch with speed; how tightly the glass follows.

number3 / 30
pressSpeed / pressBounce

The spring that opens and closes the lens.

number16 / 0.4

Accessibility

  • A native range input does the work: arrow keys, Home, End and Page Up / Down, and screen readers announce the value.
  • The label names the input.
  • With reduced motion the glass follows without springs.