HextaUI

Slider: Long labels

Long labels wrap, and the value stays on the end.

Annual household income before taxes, including side projects
$1,200 – $48,000
import { Slider, SliderLabel, SliderValue } from "@/components/ui/slider"

export function SliderLongLabel() {
  return (
    <Slider
      defaultValue={[1200, 48000]}
      min={0}
      max={50000}
      step={100}
      format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
      className="max-w-xs"
    >
      <SliderLabel>
        Annual household income before taxes, including side projects
      </SliderLabel>
      <SliderValue />
    </Slider>
  )
}

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

pnpm dlx shadcn@latest add https://hextaui.com/r/slider-long-label.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[]–
min
number0
max
number100
step
number1
format
Intl.NumberFormatOptions–
className
string | (state) => string–

Every prop is in the Slider API reference.

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