Skip to content
satin

Slider

Picks a number or a range by dragging, with the value to read or type.

Volume

Installation

Terminal
npm i @uisatin/ui
Import
import { Slider } from '@uisatin/ui/slider'

About 24.9 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The Slider component wraps the Radix slider: one slider thumb for a number, two for a [from, to] range, with a hidden input per thumb when it has a name. The label names it; formatValue is what screen readers hear. Typed values in inputs are clamped, snapped to step and kept in order on Enter or blur.

PropTypeDefault
value
number[number, number]
—
defaultValue
number[number, number]
—
onValueChange
(value: number | [number, number]) => void
—
onValueCommit
(value: number | [number, number]) => void
—
min
number
0
max
number
100
step
number
1
minStepsBetweenThumbs
number
0
label
ReactNode
—
showValue
boolean
true
inputs
boolean
false
tooltip
boolean
false
orientation
"horizontal""vertical"
"horizontal"
formatValue
(value: number) => string
—
disabled
boolean
false
name
string
—
className
string
—
ref
Ref<HTMLElement>
—
...props
ComponentProps<typeof Slider.Root>

Other attributes go to the Radix Slider.Root part

—

Accessibility

A Radix slider with a slider role per thumb, aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext from formatValue. One thumb is named by label (or aria-label); a range’s thumbs are named "From" and "To". The readout and the tooltip are hidden, since the thumbs say the value. The inputs are named "Value", or "From" and "To". Inside a form, hidden inputs carry the value.

KeyAction
←or→or↑or↓Moves the focused thumb one step.
Page UporPage DownMoves it ten steps; Shift with an arrow does the same.
HomeorEndMoves it to min or max.
EnterIn an input: clamps the typed value, snaps it to step and commits it.
EscIn an input: puts the current value back.