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%examples.tsx
1"use client";23import { useState } from "react";45import {6 MotionSlider,7 type SliderMotionPreset,8 type SliderThumbEffect,9} from "@/registry/ui/motion-slider";1011const 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}>;3233export function MotionSliderExample() {34 const [values, setValues] = useState([30, 55, 75]);3536 return (37 <div className="grid gap-8 md:grid-cols-3">38 {examples.map((example, index) => (39 <MotionSlider40 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
| Name | Type | Default | Description |
|---|---|---|---|
| value | number | 0 | The value of the slider |
| defaultValue | number | 0 | The default value of the slider |
| onValueChange | function | undefined | The function to handle the value change |
| onValueCommit | function | undefined | The function to handle the value commit |
| min | number | 0 | The minimum value of the slider |
| max | number | 100 | The maximum value of the slider |
| step | number | 1 | The step of the slider |
| disabled | boolean | false | Whether the slider is disabled |
| name | string | undefined | The name of the slider |
| label | React.ReactNode | undefined | The label of the slider |
| ariaLabel | string | undefined | The aria label of the slider |
| showValue | boolean | true | Whether the value is shown |
| formatValue | function | undefined | The function to format the value |
| motionPreset | string | undefined | The motion preset of the slider |
| thumbEffect | string | undefined | The effect of the thumb |
| className | string | undefined | The class name of the slider |