Slider

Pick a value, or a range with two thumbs, on a horizontal track. Values snap to step; the track follows dir="rtl".

StableSource
Volume
40%

Import

import { Slider } from "@meridui/react";

Examples

Range

Pass two values. Thumbs cannot cross; minStepsBetweenThumbs keeps them apart. Name each thumb with thumbLabels and give values a readable form with getValueText.

Price
$200 – $800

Decimal steps, disabled and RTL

API reference

Renders a div; other div attributes and the ref go on it. For a single thumb, aria-label / aria-labelledby on the root name the thumb.

PropTypeDefaultDescription
valuenumber[]–Controlled values: one for a single slider, two for a range.
defaultValuenumber[][min]Initial values when uncontrolled.
onValueChange(value: number[]) => void–Called on every change while dragging or pressing keys.
onValueCommit(value: number[]) => void–Called when a drag ends or after a key press.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Increment.
largeStepnumberstep * 10Increment for Page Up / Page Down and Shift + arrows.
minStepsBetweenThumbsnumber0Minimum distance between range thumbs, in steps.
thumbLabelsstring[]["Minimum", "Maximum"] for a rangeAccessible name of each thumb.
getValueText(value: number, index: number) => string–aria-valuetext, e.g. with a unit or currency.
disabledbooleanfalseDisables the slider.
namestring–Hidden input per thumb: name for one thumb, name[] for a range.

Styling

ClassElement
.mrd-sliderRoot (data-disabled)
.mrd-slider__trackTrack, and the pointer target
.mrd-slider__rangeFilled part of the track
.mrd-slider__thumbThumb, role="slider"

Accessibility

Each thumb is a role="slider" with aria-valuenow, aria-valuemin and aria-valuemax. In a range, the limits of each thumb are the other thumb's value, so screen readers report the real bounds. The track has a 24px hit area and each thumb a 24px target (44px on coarse pointers).

KeyAction
ArrowRightArrowUpIncrease by step (ArrowRight decreases in RTL).
ArrowLeftArrowDownDecrease by step (ArrowLeft increases in RTL).
PageUpPageDownIncrease / decrease by largeStep. Shift + arrows do the same.
HomeEndSet to the minimum / maximum.