HextaUI

Slider: Steps and format

step snaps the value, largeStep sets the Page Up and Shift + arrow jump, and format formats every number the slider shows or announces.

Playback speed
1.00
import { Slider, SliderLabel, SliderValue } from "@/components/ui/slider"

export function SliderSteps() {
  return (
    <Slider
      defaultValue={1}
      min={0.5}
      max={2}
      step={0.25}
      largeStep={0.5}
      format={{ minimumFractionDigits: 2 }}
      className="max-w-xs"
    >
      <SliderLabel>Playback speed</SliderLabel>
      <SliderValue />
    </Slider>
  )
}

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

pnpm dlx shadcn@latest add https://hextaui.com/r/slider-steps.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
largeStep
number10
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.