Slider
A range slider with a glass thumb: a small pill at rest that opens into a wide lens while you hold it.
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/reactSlider, 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
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
Coming soon
API reference
| Prop | Type | Default |
|---|---|---|
valueCurrent value. | number | 50 |
onChangeCalled with the new value. | (value: number) => void | — |
min / max / stepThe range and its step. | number | 0 / 100 / 1 |
labelLabel above the track; an empty string hides it. | string | 'Volume' |
showValueShows the value next to the label. | boolean | true |
sizeTrack height 8, 12, 18 or 26 px; the glass scales with it. | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
startIcon / endIconIcons at either end of the track. | IconName | 'none' | 'none' |
colorThe filled part of the track: a hex, | string | '#3291FF' |
themeOverrides the page theme for this slider. | 'light' | 'dark' | — |
restFrostThe thumb at rest: 1 = a white pill, 0 = clear glass. Held, it is always clear glass. | number | 1 |
refractionHow far the lens bends what lies beneath. | number | 37 |
dispersion / rimIntensity / magnificationColour fringing, rim light and zoom of the lens. | number | 0.12 / 0.55 / 0 |
motionStretch / motionSmoothingSquash and stretch with speed; how tightly the glass follows. | number | 3 / 30 |
pressSpeed / pressBounceThe spring that opens and closes the lens. | number | 16 / 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
labelnames the input. - With reduced motion the glass follows without springs.