Range Slider

A stepped slider whose thumb bounces as it lands on each tick.

Preview

"use client";

import { useState } from "react";

import { RangeSlider } from "@/components/motion/range-slider";

export function RangeSliderPreview() {
  const [value, setValue] = useState(40);

  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <div className="flex items-center justify-between text-sm text-muted-foreground">
        <span>Drag the handle</span>
        <span className="tabular-nums text-foreground">{value}</span>
      </div>
      <RangeSlider sound value={value} onValueChange={setValue} step={5} aria-label="Value" />
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/range-slider

API Reference

showTicks?
boolean

Render a tick dot at each step.

Defaulttrue
className?
string

Classes merged onto the slider track.

Default—
value?
number

The current value, for controlled use.

Default—
defaultValue?
number

The initial value when uncontrolled. Default: 0

Default—
onValueChange?
((value: number) => void)

Called with the snapped value whenever a drag or key press changes it.

Default—
min?
number

Lowest value on the track. Default: 0

Default—
max?
number

Highest value on the track. Default: 100

Default—
step?
number

Increment values snap to when dragging or using arrow keys. Default: 1

Default—
disabled?
boolean

Ignores pointer and keyboard input. Default: false

Default—
aria-label?
string

Accessible name for the slider handle.

Default—
formatValueText?
((value: number) => string)

Announced instead of the raw number — pass one when the value carries a unit or a suffix ("72.5 kg", "35%"); a bare number needs no valueText.

Default—
sound?
boolean

Play a tiny tick per step, higher toward the max. Off by default; a `SoundProvider` can mute it app-wide.

Default—
Also on React Native. A bar thumb that glides between steps.

More in Range Slider

Updated