Slider
The thumb grows while you drag, the fill springs to new values and the digits roll.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/sliderThis adds components/keyframery/slider.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack } from "@/components/keyframery/slider"
export default function Usage() {
return (
<Slider defaultValue={50} aria-label="Volume">
<SliderControl>
<SliderTrack>
<SliderIndicator />
<SliderThumb />
</SliderTrack>
</SliderControl>
</Slider>
)
}Anatomy
How the parts fit together:
Slider
└── SliderControl
└── SliderTrack
├── SliderIndicator
└── SliderThumbExamples
With a value
SliderValue shows the number, and format takes Intl.NumberFormat options.
Range
Pass two values for two thumbs. minStepsBetweenThumbs keeps them apart.
Vertical
orientation="vertical" stands it up, for an equaliser or a zoom control.
Motion
| Move | What you see |
|---|---|
| Pop | The thumb grows while you hold it. |
| Spring | The fill and thumbs travel on a spring when the value jumps. |
| Roll | The value rolls to the new number. |
Timing and springiness follow the motion style you set. To change how fast this slider moves, pass speed:
<Slider speed="fast">
…
</Slider>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--slider-track | Empty track | --muted; --accent in dark |
--slider-fill | Filled range | --primary |
--slider-thumb | Thumb face | --background; foreground mixed with 8% background in dark |
--slider-thickness | Track thickness | 0.375rem |
--slider-thumb-size | Thumb diameter | 1rem |
--slider-radius | Track and thumb corners | 9999px |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK slider reference.
Slider
Renders a <div>, and takes its props too.
Prop
Type
SliderThumb
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
SliderControl: a<div>SliderTrack: a<div>SliderIndicator: a<div>SliderValue: a<output>
Keyboard
| Key | What it does |
|---|---|
| ← → | Moves the focused thumb a step. |
| Shift + ← | Moves ten steps at a time. |
| Page Up | Moves ten steps. |
| Home | Moves to the minimum. |
| End | Moves to the maximum. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's slider with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/slider"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/slider"Questions
How does the animated Slider for UI SDK move?
Pop: The thumb grows while you hold it. Spring: The fill and thumbs travel on a spring when the value jumps. Roll: The value rolls to the new number.
Do I need Motion or Framer Motion for the animated Slider?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/slider instead. It has the same parts and props as @ui-sdk/react/slider and adds motion only.
What happens to the Slider when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.