Slider whose thumb is a soft ball: it stretches toward the pull, follows the finger, squashes on the walls; the fill is a pill and the value bubble morphs out of the thumb. Single or range.
DragDrag
Alert thresholds
When the monitoring agent pages the on-call engineer.
CPU alert aboveSustained for 5 minutes
80%
Response time windowRequests outside it are flagged
200–800 ms
Log retentionOlder entries are archived
90 days
slider · , lively
slider-demo.tsx
When to use
Use to pick a number or a range by dragging. Presets: bubble, ticks (marks) and input (adds a number box). Range takes two values.
When not to use
When the exact value matters more, use the input preset or Number Input. For a few named options use Segmented Control.
Use a slider to pick a number or a range by dragging: a threshold, a price window, a retention period. When the exact value matters more than the gesture, use the input preset or a plain text field. For a handful of named options, use a segmented control or radio group.
The slider follows the MotionKit motion grammar in three beats. Pressing the thumb charges it: the ball stretches toward the pointer, and even a quick click, tap or key press shows the whole stretch before it springs back. Dragging is the action: the thumb follows the pointer one to one, the fill is a pill that ends at the thumb, and a value bubble morphs out of the thumb. Releasing settles it: the thumb springs to the nearest step, squashes against the track end at the minimum or maximum, and the bubble folds back. In a range the thumbs cannot cross, so each one is the other's wall.
Set the character for the whole app with MotionKitProvider temperament="calm", or per slider with temperament="playful". The preset prop picks the layout, with the same look and motion: bubble (default, value bubble while dragging or focused), ticks (pass marks; the nearest labelled mark is highlighted instead of the bubble) and input (a number box beside the track, synced both ways). size is sm, md or lg, and orientation="vertical" rotates the axis.
With minStepsBetweenThumbs={0} (the default) the two thumbs of a range can sit on the same value: one covers the other, and the thumb in hand (the one last pressed, stepped or hovered) is drawn on top, so its squash against the other stays visible. A press on two thumbs pinned at an end takes the one that can still move. The range demo routes a single ticket priority this way.
The default demo shows alert thresholds in a monitoring panel: a single slider, a latency range with a minimum window that shows an error message (aria-invalid), and a switch that disables all of them.
Built on Radix Slider: every thumb is a real role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and aria-orientation. aria-valuetext is the output of formatValue, so a screen reader announces "80%" or "200 ms" rather than a bare number.
Give the slider an accessible name with aria-label or aria-labelledby. For a range, name each thumb with thumbLabels (for example "Minimum price", "Maximum price"); with aria-labelledby the range is wrapped in a group.
aria-invalid is passed to the thumbs; show the message next to the slider. The slider never refuses a position, validation belongs to the form.
The value bubble, ticks, ghost tick, fill, halo and track are decorative and aria-hidden; the state is exposed by the thumbs.
The thumb hit area is at least 24 px and grows to 44 px on coarse pointers. On touch, the bubble appears on drag start and a tap on the track throws the thumb there.
Colors come from your shadcn tokens (muted, primary, background, border, ring, foreground), so contrast follows your theme in light and dark. Focus shows a 3px ring around the thumb.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") there is no stretch or squash. The thumb still follows the pointer, glides to keyboard steps in the short fade time, the bubble crossfades above it and the ticks change color at once. Nothing disappears: the value, bubble, fill and marks all remain.
The thumb, the fill and the bubble animate transform and opacity. While dragging, one motion value per thumb is set from the pointer; stretch, squash and the fill are derived from it, so React does not re-render per frame.
There are no ambient loops: every movement is caused by a drag, a key, a click on the track or a value change, so nothing runs while the slider is idle, off screen or in a hidden tab.
The component installs @radix-ui/react-slider and motion; it is not heavy and has no lazy parts.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-slider, motion.
Dependencies
@radix-ui/react-slider · peer
motion · peer
Triggers
drag, press, keyboard focus, a value change
Reduced motion
No stretch or squash: the thumb still follows the finger and glides to keyboard steps in the fade time, the bubble crossfades above it and the ticks change color at once.
Keyboard
ArrowRight / ArrowUp
Increases the focused thumb by one step (the thumb charges while the key is down)
ArrowLeft / ArrowDown
Decreases the focused thumb by one step
Shift + Arrow, PageUp / PageDown
Moves the focused thumb by ten steps
Home / End
Moves the focused thumb to the minimum or maximum (it lands with the wall squash)
Tab / Shift+Tab
Moves focus to the next or previous thumb
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)