Skip to content

Slider

Selects a value or range on a track between a minimum and maximum.

40
slider-demo.tsx

Installation

The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.

Composition

  • Slider

    Owns the values. Without children, it renders a label, value, and one handle per value.

    • SliderLabel
    • SliderValue
    • SliderTrack
      • SliderRail
        • SliderRange
      • SliderHandleRepeats

        One per value. Set index on each.

    • SliderMarksOptional

Range

Use thumbLabels to give each handle a name.

$200 – $800
slider-range-demo.tsx

Marks

Set step to the mark interval so the handle stops on each mark.

50%
slider-step-demo.tsx

Vertical

+4
-2
+6
slider-vertical-demo.tsx

Custom layout

Without a visible label, pass aria-label to Slider.

slider-custom-demo.tsx

Disabled

20
slider-disabled-demo.tsx

API reference

vip/ui adds or changes the props below. For all other props, see React Aria Slider (opens in a new tab).

Slider

label: string
Label above the track, next to the value.
thumbLabels: string[]
Names each handle, in value order. Give one when defaultValue or value is an array.
marks: number[]
Values to label along the track. For custom labels, compose SliderMarks.
fillOffset: number
The value the fill starts from. Set 0 for a range that goes below zero.
orientation: "horizontal" | "vertical" = "horizontal"
A vertical slider is 14rem tall. Set the height with className.

SliderMarks

values: number[]Required
The values to label. Labels in the selected range use the foreground color.
children: (value: number) => ReactNode
Renders each label. Without it, the slider formatOptions format the value.
offset: number
The offset of the SliderRange fill, so labels in the filled part use the foreground color.