Skip to main content

Slider

A single-thumb range slider with pointer + keyboard control.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

A single-thumb range slider with pointer + keyboard control.

Accessibility​

Arrow keys adjust by step, Home/End jump to min/max; value is announced via aria-valuenow/aria-valuetext.

Install and import​

npx shadcn@latest add @prism/slider
import { Slider } from '@/components/prism/Slider';

In a no-build prototype, read it from the bundle instead: const { Slider } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
labelstring—
valuenumber | null—Controlled value; null means "not set yet" (still controlled).
defaultValuenumber | null—Initial value; null starts unset. Default 50.
unsetLabelstring—Shown instead of the value while unset. Default "Not set".
namestring—Form field name: the value submits natively ("" while unset).
formstring—Id of the form to submit with, when the slider sits outside it.
minnumber—
maxnumber—
stepnumber—Granularity when free-flowing (ignored when snap is set). Default 1.
keyboardStepnumber—How far an arrow key moves. Default step.
pageStepnumber—How far Page Up / Page Down (and Shift+arrows) move. Default a tenth of the range.
snapnumber[]—Optional snap detents. When given, the thumb snaps to the NEAREST of these values (during drag and via arrow keys) and tick marks render on the track. Omit for the default free-flowing behaviour. e.g. snap={[0, 25, 50, 75, 100]}.
onChange(value: number) => void—
formatValue(value: number) => string—Format the displayed value, e.g. (v) => ${v}%.
isDisabledboolean—
classNamestring—