All components

Motion Slider

A slider component that uses motion to animate the slider.

Default
Default motion slider
Responsive scale
30%
Smooth lift
55%
Soft trailing glow
75%
1"use client";
2
3import { useState } from "react";
4
5import {
6 MotionSlider,
7 type SliderMotionPreset,
8 type SliderThumbEffect,
9} from "@/registry/ui/motion-slider";
10
11const examples = [
12 {
13 label: "Responsive scale",
14 preset: "snappy",
15 effect: "scale",
16 },
17 {
18 label: "Smooth lift",
19 preset: "smooth",
20 effect: "lift",
21 },
22 {
23 label: "Soft trailing glow",
24 preset: "slow",
25 effect: "glow",
26 },
27] satisfies Array<{
28 label: string;
29 preset: SliderMotionPreset;
30 effect: SliderThumbEffect;
31}>;
32
33export function MotionSliderExample() {
34 const [values, setValues] = useState([30, 55, 75]);
35
36 return (
37 <div className="grid gap-8 md:grid-cols-3">
38 {examples.map((example, index) => (
39 <MotionSlider
40 key={example.label}
41 label={example.label}
42 value={values[index]}
43 onValueChange={(nextValue) => {
44 setValues((current) =>
45 current.map((value, valueIndex) =>
46 valueIndex === index ? nextValue : value,
47 ),
48 );
49 }}
50 min={0}
51 max={100}
52 step={1}
53 motionPreset={example.preset}
54 thumbEffect={example.effect}
55 formatValue={(value) => `${value}%`}
56 />
57 ))}
58 </div>
59 );
60}

Installation & source

Install via the shadcn CLI or copy the registry files manually.

bash
npx shadcn@latest add @tt-ui/motion-slider

Props

NameTypeDefaultDescription
valuenumber0The value of the slider
defaultValuenumber0The default value of the slider
onValueChangefunctionundefinedThe function to handle the value change
onValueCommitfunctionundefinedThe function to handle the value commit
minnumber0The minimum value of the slider
maxnumber100The maximum value of the slider
stepnumber1The step of the slider
disabledbooleanfalseWhether the slider is disabled
namestringundefinedThe name of the slider
labelReact.ReactNodeundefinedThe label of the slider
ariaLabelstringundefinedThe aria label of the slider
showValuebooleantrueWhether the value is shown
formatValuefunctionundefinedThe function to format the value
motionPresetstringundefinedThe motion preset of the slider
thumbEffectstringundefinedThe effect of the thumb
classNamestringundefinedThe class name of the slider