WebberUI

Elastic Slider

A slider whose thumb stretches with spring physics — drag past the boundary and the track extends like a rubber band, then springs back.

A slider with damped physics: drag past an end point and the track extends against resistance while the icons are pushed aside by the thumb, then springs back on release. It supports controlled and uncontrolled modes, keyboard operation, and the reduce-motion preference.

Loading preview…
npx shadcn@latest add https://webberui.com/r/elastic-slider.json

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

100
1
50
<ElasticSlider />

Installation

npx shadcn@latest add https://webberui.com/r/elastic-slider.json

Or, once registries are configured in components.json, install it as @webberui/elastic-slider.

Usage

import { ElasticSlider } from "@/components/ui/elastic-slider";

<ElasticSlider defaultValue={40} showValue />;

Controlled usage: pass value and onValueChange.

const [value, setValue] = React.useState(50);

<ElasticSlider value={value} onValueChange={setValue} />;

Props

PropTypeDefaultDescription
defaultValuenumber50Initial value in uncontrolled mode
valuenumberControlled value; when provided, it is driven by external state
onValueChange(value: number) => voidCallback for value changes (fires on drag, keyboard, and click alike)
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step size; set 0 for a continuous value
leftIconReact.ReactNode<Minus />Icon on the left (decrease end)
rightIconReact.ReactNode<Plus />Icon on the right (increase end)
showValuebooleanfalseWhether to show the current value
maxOverflownumber50Maximum overflow past the boundary (px); higher is more elastic
classNamestringForwarded to the outermost container

Accessibility

  • The container carries role="slider" with aria-valuemin / aria-valuemax / aria-valuenow, and is focusable
  • Keyboard support: arrow keys adjust by one step, Home / End jump to the minimum and maximum
  • When the user has "reduce motion" enabled at the system level, the stretch and spring-back animations are disabled and only the live value reading remains

On this page