Skip to Content
zjkm-ui
Components

Bubble Slider

A slider with its value in a bubble over the thumb.

50%
Props
<BubbleSlider label="Brightness" />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/bubble-slider.json
import { BubbleSlider } from "@/components/bubble-slider"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

The value rides above the thumb in a small bubble, so the number sits right where you're looking.

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

export function Brightness() {
  return <BubbleSlider label="Brightness" format={(v) => `${v}%`} />;
}

Props

PropTypeDefaultDescription
labelstringThe label.
defaultValuenumber50Starting value.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Step between values.
format(value: number) => stringStringTurns the value into the text shown and read out, e.g. v => `${v}%`.
onChange(value: number) => voidCalled as the value changes.
colorstring"#4f46e5"Bubble and fill colour.
classNamestringClasses for the wrapper.

With reduced motion, the bubble moves without easing.

On this page