Pro--% off in--d : --h : --m : --s
HeroUI

Slider

Migration guide for Slider from HeroUI v2 to v3

Refer to the v3 Slider documentation for complete API reference, styling guide, and advanced examples. This guide only focuses on migrating from HeroUI v2.

Structure Changes

In v2, Slider used a simple structure with props:

import { Slider } from "@heroui/react";

export default function App() {
  return (
    <Slider
      label="Volume"
      defaultValue={30}
      size="md"
      color="primary"
    />
  );
}

In v3, Slider requires compound components:

import { Slider, Label } from "@heroui/react";

export default function App() {
  return (
    <Slider defaultValue={30}>
      <Label>Volume</Label>
      <Slider.Output />
      <Slider.Track>
        <Slider.Fill />
        <Slider.Thumb />
      </Slider.Track>
    </Slider>
  );
}

Key Changes

1. Component Structure

v2: Simple Slider with props
v3: Compound components: Slider.Output, Slider.Track, Slider.Fill, Slider.Thumb

2. Prop Changes

v2 Propv3 LocationNotes
labelUse Label component
sizeRemoved (use Tailwind CSS)
colorRemoved (use Tailwind CSS)
radiusRemoved (use Tailwind CSS)
classNamesUse className props on individual components
showStepsNot yet supported
showTooltipNot yet supported
marksNot yet supported (see Slider.Marks)
startContentCustomize track wrapper directly
endContentCustomize track wrapper directly
hideValueOmit Slider.Output
hideThumbOmit Slider.Thumb
showOutlineUse Tailwind CSS
renderThumbUse Slider.Thumb render prop
renderLabelUse Label component
renderValueUse Slider.Output render prop
getValueUse Slider.Output render prop
getTooltipValueUse Slider.Output render prop
fillOffsetNot yet supported
disableThumbScaleUse Tailwind CSS
disableAnimationRemoved
onChangeEndSliderStill supported — handler called when the user finishes dragging a thumb

Migration Examples

Controlled Slider

import { useState } from "react";

const [value, setValue] = useState(25);

<Slider
  value={value}
  onChange={setValue}
  label="Volume"
/>
import { useState } from "react";

const [value, setValue] = useState(25);

<Slider value={value} onChange={setValue}>
  <Label>Volume</Label>
  <Slider.Output />
  <Slider.Track>
    <Slider.Fill />
    <Slider.Thumb />
  </Slider.Track>
</Slider>

Range Slider

<Slider
  defaultValue={[100, 500]}
  formatOptions={{style: "currency", currency: "USD"}}
  label="Price Range"
  maxValue={1000}
  minValue={0}
  step={50}
/>
<Slider
  defaultValue={[100, 500]}
  formatOptions={{style: "currency", currency: "USD"}}
  maxValue={1000}
  minValue={0}
  step={50}
>
  <Label>Price Range</Label>
  <Slider.Output />
  <Slider.Track>
    {({state}) => (
      <>
        <Slider.Fill />
        {state.values.map((_, i) => (
          <Slider.Thumb key={i} index={i} />
        ))}
      </>
    )}
  </Slider.Track>
</Slider>

Vertical Slider

<Slider
  defaultValue={30}
  orientation="vertical"
  label="Volume"
/>
<Slider defaultValue={30} orientation="vertical">
  <Label>Volume</Label>
  <Slider.Output />
  <Slider.Track>
    <Slider.Fill />
    <Slider.Thumb />
  </Slider.Track>
</Slider>

Custom Value Display

<Slider
  renderValue={(props) => (
    <output {...props}>Custom: {value}</output>
  )}
  label="Volume"
  defaultValue={30}
/>
<Slider defaultValue={30}>
  <Label>Volume</Label>
  <Slider.Output>
    {({state}) => `Custom: ${state.values[0]}`}
  </Slider.Output>
  <Slider.Track>
    <Slider.Fill />
    <Slider.Thumb />
  </Slider.Track>
</Slider>

Component Anatomy

The v3 Slider follows this structure:

Slider (Root)
  ├── Label (optional)
  ├── Slider.Output (optional)
  └── Slider.Track
      ├── Slider.Fill
      └── Slider.Thumb (or multiple for range)

For range sliders, use a render prop in Slider.Track:

<Slider.Track>
  {({state}) => (
    <>
      <Slider.Fill />
      {state.values.map((_, i) => (
        <Slider.Thumb key={i} index={i} />
      ))}
    </>
  )}
</Slider.Track>

Summary

  1. Component Structure: Must use compound components (Slider.Output, Slider.Track, Slider.Fill, Slider.Thumb)
  2. Label Handling: label prop removed - use Label component
  3. Styling Props Removed: size, color, radius - use Tailwind CSS
  4. ClassNames Removed: Use className props on individual components
  5. Feature Props Removed: showSteps, showTooltip, marks, startContent, endContent - not yet supported or customize manually
  6. Render Props Removed: renderThumb, renderLabel, renderValue - use render props on components
  7. Visibility Props Removed: hideValue, hideThumb - omit components instead
  8. Range Sliders: Must map over thumbs in Slider.Track render prop
  9. onChangeEnd: Still supported on Slider — fires when the user finishes dragging a thumb

On this page