Bubble Slider

A value bubble pops from the thumb and tilts with how fast you drag.

Contributed by Avinit(opens in a new tab)

Preview

"use client";

import { useState } from "react";

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

export function RangeSliderBubblePreview() {
  const [value, setValue] = useState(28);

  return (
    <div className="flex w-full max-w-sm flex-col gap-1">
      <span className="text-sm text-muted-foreground">Drag fast and the bubble leans</span>
      <BubbleSlider sound value={value} onValueChange={setValue} aria-label="Value" />
    </div>
  );
}

Install

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

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

API Reference

format?
((value: number) => string)

Formats the value shown in the bubble.

Default—
className?
string

Classes merged onto the root element.

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