This page as markdown: /slider.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Slider

Status: stable

Slider over Base UI Slider — pointer + keyboard control, ARIA slider wiring, and range support via multiple thumbs. The default export composes Root + Control + Track + Indicator + Thumb; pass an array value for a range.

Keywords: slider, range, value, input

Usage

Use Slider for bounded numeric choices where approximate adjustment is faster than typing.

Best practices

Anatomy

Part Required Description
SliderRoot yes The controlled slider wrapper.
SliderControl yes The interactive slider control region.
SliderTrack yes The visible value range.
SliderIndicator no The filled portion of the track.
SliderThumb yes The draggable handle.
SliderValue no A readable value display.

Subcomponents

Name Type Description
SliderRoot Base UI Slider.Root props The unstyled Base UI Root for custom composition — owns the value state and forwards value / defaultValue / onValueChange / min / max / step. Drag state surfaces via data-[dragging]. The default Slider export wires all the parts for you.
SliderControl Base UI Control props + className The interactive track lane — the positioning context the indicator and thumbs sit in; dims when disabled.
SliderTrack Base UI Track props + className The full-range rail beneath the indicator.
SliderIndicator Base UI Indicator props + className The filled portion from min (or the lower thumb) to the current value.
SliderThumb Base UI Thumb props + className A draggable handle: a fixed-size hit target wrapping a decorative dot. The dot rests small and scales to full size on hover, keyboard focus, and drag; the box never changes, so row metrics and the tap target hold. Range sliders render one per value; pass index for SSR. Interaction state surfaces via data-[dragging].
SliderValue Base UI Value props Formatted value readout for custom compositions (e.g. a live number beside the control).

Props

Name Type Default Description
value number | number[] — Controlled value. An array renders a range slider with one thumb per entry.
defaultValue number | number[] — Uncontrolled initial value. An array renders a range slider.
onValueChange (value, eventDetails) => void — Fires on every value change. value is a number (or number[] for a range).
min number 0 Minimum allowed value.
max number 100 Maximum allowed value.
step number 1 Granularity the slider steps through. Snaps to multiples.
disabled boolean false Ignore user interaction and dim the control.
orientation 'horizontal' | 'vertical' horizontal Axis the slider tracks along. A vertical slider has no intrinsic length — give it a height (h-40, or flex-1 in a column).
aria-label string — Accessible name, applied to each thumb's input (the element with role=slider). A range also names its group with it.
getAriaLabel (index) => string — Per-thumb name for a range ("Minimum price" / "Maximum price"). Wins over aria-label on the thumbs.
getAriaValueText (formattedValue, value, index) => string — What a screen reader announces for the value when the number alone is wrong — a seek bar's "1:23 of 3:45". For units or percent, format (Intl.NumberFormatOptions) is enough.

Tokens used

secondary, primary, background, ring

Motion

Accessibility

Related

Examples

Single value

import { Slider } from "@sableui/react"

<Slider defaultValue={50} aria-label="Volume" />

Range

import { Slider } from "@sableui/react"

const [range, setRange] = useState([20, 60])
<Slider value={range} onValueChange={setRange} aria-label="Price range" getAriaLabel={(i) => (i ? "Maximum price" : "Minimum price")} />

Seek bar with spoken time

import { Slider } from "@sableui/react"

<Slider value={position} max={duration} onValueChange={seek} aria-label="Seek" getAriaValueText={(_, v) => `${formatTime(v)} of ${formatTime(duration)}`} />

Stepped

import { Slider } from "@sableui/react"

<Slider defaultValue={40} min={0} max={100} step={10} />

Vertical

import { Slider } from "@sableui/react"

<div className="h-40"><Slider orientation="vertical" defaultValue={40} aria-label="Level" /></div>

Composed with a value readout

import { Field, SliderControl, SliderIndicator, SliderRoot, SliderThumb, SliderTrack, SliderValue } from "@sableui/react"

<Field label="Volume"><SliderRoot defaultValue={40} className="flex items-center gap-3"><SliderControl><SliderTrack><SliderIndicator /><SliderThumb /></SliderTrack></SliderControl><SliderValue className="text-mono-sm" /></SliderRoot></Field>