ValyroUI Русская версия

Slider

Range slider. Free, MIT · Forms and input › Checkboxes and sliders

Single-value or range slider. aria-label / aria-labelledby / aria-describedby are applied to the thumbs. Each thumb holds a visually hidden native <input type="range">, as React Aria's does: it is what takes focus, so VoiceOver on iOS and TalkBack can change the value with their swipe gestures (they do not adjust an ARIA slider), and the keys below keep the behaviour the same on every platform.

Installation

npx valyro-cli@latest add slider
npx shadcn@latest add https://valyro.xyz/r/slider.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { Slider } from 'valyro-ui';

Props

PropTypeDefault
valueTA number for one thumb, a [from, to] tuple for a range.
defaultValueTInitial value when uncontrolled.
onValueChange(value: SliderWiden<T>) => voidCalled with the new value when it changes.
minnumber0Lowest value, at the start of the track; steps are counted from it.
maxnumber100Highest value, at the end of the track.
stepnumber1Snapping interval; 0 = continuous.
marksSliderMark[]Ticks on the track, with optional labels below it.
tooltipboolean | 'always'falseValue bubble over the thumb: true while hovered/focused/dragged, 'always' permanently.
formatValue(value: number) => stringText for the bubble and aria-valuetext. Default: the number formatted for locale.
localestringLocale for the default formatValue (default: the ThemeProvider's, then the browser's).
thumbLabels[string, string]Words appended to the accessible name of each range thumb, e.g. "Price minimum".
disabledbooleanfalseIgnores pointer and keyboard input, takes the thumbs out of Tab order and leaves the value out of form data.
namestringSubmits the value(s) with the surrounding form through hidden inputs.
invalidbooleanfalseError state, e.g. from a FormField: aria-invalid on the thumbs (an explicit aria-invalid wins).

Related components

Previous: Switch · Next: Histogram Range · All Forms and input