HextaUI

Slider: Value bubble

showValue shows the formatted value above the thumb while it is dragged or focused from the keyboard. Use it instead of a label row, since the bubble rises into the space above the track.

import { Slider } from "@/components/ui/slider"

export function SliderValueBubble() {
  return (
    <div className="flex w-full max-w-xs flex-col gap-10 pt-8">
      <Slider
        defaultValue={0.4}
        max={1}
        step={0.01}
        format={{ style: "percent" }}
        showValue
        aria-label="Opacity"
      />
      <Slider defaultValue={[30, 70]} showValue aria-label="Range" />
    </div>
  )
}

This adds the example as components/examples/slider/value-bubble.tsx, together with the Slider component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/slider-value-bubble.json

To add only the component, follow the Slider installation.

Props in this example

The Slider props this example sets, from the API reference.

PropTypeDefault
defaultValue
number | number[]–
max
number100
step
number1
showValueShows the value above the thumb while dragging or keyboard-focused.
booleanfalse
format
Intl.NumberFormatOptions–
aria-labelNames the thumbs.
string–

Every prop is in the Slider API reference.

See them all, with keyboard support and accessibility notes, on the Slider page.