Skip to content

Elastic Slider

A range slider with a flexible track and a soft spring return.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import ElasticSlider from "./ElasticSlider";
export default function Example() {
return (
<ElasticSlider
defaultValue={64}
min={0}
max={100}
step={1}
label={"Volume"}
unit={"%"}
accentColor={"#dcc5f2"}
trackColor={"#ffffff24"}
elasticity={0.35}
showValue={true}
disabled={false}
/>
);
}

Using Elastic Slider

Set min, max, and step for the values your application accepts. Use label and unit to explain the number being adjusted.

Pair value with onChange for a controlled slider, or use defaultValue for local state. elasticity changes the visual response without changing the allowed range.

Props

NameTypeRequiredDefaultDescription
valuenumberNoundefinedOptional controlled numeric value.
defaultValuenumberNo50Initial value when uncontrolled.
onChangefunctionNoundefinedCalled with the new numeric value. Native range keyboard controls are supported.
minnumberNo0Minimum value.
maxnumberNo100Maximum value. A max at or below min disables the slider.
stepnumberNo1Native range step size.
labelstringNo""Visible and accessible field label.
unitstringNo""Suffix shown with the current value.
accentColorstringNo"#d6c4f2"Filled track and thumb colour.
trackColorstringNo"#ffffff24"Unfilled track colour.
elasticitynumberNo0.35Vertical drag multiplier, with displacement capped at 18 pixels.
showValuebooleanNotrueDisplay the current value beside the label.
disabledbooleanNofalseDisable user input.
classNamestringNo""Additional CSS classes, merged with the component styles.
styleCSSPropertiesNoundefinedInline styles for caller-defined sizing and visual overrides.

Related components

A recessed password field pairs a reveal control with an optional strength indicator.

Editable tags collect inside a softly framed input with individual remove controls.

A recessed search field expands into a polished capsule as you type.

Faceted stars lift into selection with a small marker beneath the chosen rating.