Fluid Slider

A thumbless slider whose fill flips the label color as it slides under it.

Contributed by Avinit(opens in a new tab)

Preview

"use client";

import { useState } from "react";

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

export function RangeSliderFluidPreview() {
  const [value, setValue] = useState(35);

  return (
    <div className="w-full max-w-sm">
      <FluidSlider
        sound
        value={value}
        onValueChange={setValue}
        label="Brightness"
        aria-label="Brightness"
      />
    </div>
  );
}

Install

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

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

API Reference

label?
string

Text shown on the left of the track.

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

Formats the value shown on the right.

Default(v) => `${v}%`
className?
string

Classes merged onto the slider track, 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