Elastic Slider

Slider with elastic rubber-band drag and magnetic snap feedback.

Last updated January 1, 1980

CreditsModifiedPublished

Copied from Josh Puckett — Interface Craft and Chánh Đại — Elastic Slider.

  • Value 0 now maps to the reading start (right edge in RTL) instead of always the physical left, matching a native <input type="range"> in RTL browsers
  • Arrow key direction follows reading direction: ArrowRight decreases the value in RTL instead of always increasing it
  • Fill, handle, hash marks, label, and value text use logical start/end positioning instead of left/right

Overview

Installation

Usage

import { ElasticSlider } from "@/components/elastic-slider"
 
const [opacity, setOpacity] = useState(0.5)
 
<ElasticSlider
  label="Opacity"
  min={0}
  max={1}
  value={opacity}
  onValueChange={setOpacity}
/>

Uncontrolled:

<ElasticSlider label="Opacity" min={0} max={1} defaultValue={0.5} />

Range slider

Need two handles on one track — a min and a max, like a price filter? Use Elastic Range Slider instead.

Examples

RTL

Keyboard

Keys

API Reference

ElasticSlider