Inputs

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.

Bring this into your project

Run this command in your project folder. The CLI adds the source and dependencies; then follow the usage example below.

npx webberui@latest add elastic-slider.en

New project or installation trouble? Start here →

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
Active edited usageDefault props
<ElasticSlider/>

The complete example includes the preview layout and data. Install the component first, then paste this file into your project.

Installation

npx webberui@latest add https://webberui.com/r/elastic-slider.en.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
valuenumber—Controlled value; when provided, it is driven by external state
onValueChange(value: number) => void—Callback 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
classNamestring—Forwarded 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