Slider

An input where the user selects a value from within a given range.

<Slider defaultValue={50}>
  <Label>Volume</Label>
  <SliderControl />
</Slider>

Installation

npx shadcn@latest add @dotui/slider

Usage

Use slider to allow users to select a value from within a given range.

import { Slider, SliderControl } from '@/components/ui/slider'
<Slider defaultValue={50}>
  <SliderControl />
</Slider>

Anatomy

SliderControl renders the track, fill, and thumbs for you, so most sliders only need Slider + SliderControl. Compose the parts by hand for full control over layout.

import {
  Slider,
  SliderControl,
  SliderTrack,
  SliderFill,
  SliderThumb,
  SliderOutput,
} from '@/components/ui/slider'
;<Slider>
  <SliderOutput />
  <SliderControl>
    <SliderTrack>
      <SliderFill />
    </SliderTrack>
    <SliderThumb />
  </SliderControl>
</Slider>

Value

A single number renders a standard slider; a number[] renders a multi-thumb range. Use defaultValue for uncontrolled state, or value with onChange to control it.

<Slider defaultValue={[200, 300]} minValue={100} maxValue={500}>
  <SliderControl />
</Slider>

Range and step

minValue and maxValue set the bounds (default 0100), and step snaps movement to fixed increments.

<Slider minValue={0} maxValue={100} step={5} defaultValue={50}>
  <SliderControl />
</Slider>

Format

formatOptions accepts any Intl.NumberFormat options to format the SliderOutput label, such as currency or percent.

<Slider
  formatOptions={{ style: 'currency', currency: 'JPY' }}
  defaultValue={60}
>
  <SliderOutput />
  <SliderControl />
</Slider>

Examples

Default

Volume Control

50
Adjust the volume.

Price Range Selector

200 - 300

Quantity Picker

50 of 100 Donuts

Currency Price

¥60

API Reference

Slider

A slider allows a user to select one or more values within a range.

PropType
ReactNode | function
boolean
Orientation
number | number[]
number | number[]
function
function
NumberFormatOptions

SliderControl

A slider control is the interactive surface that positions the track and thumbs.

PropType
ReactNode | function

SliderTrack

A slider track is the visual track that contains the selected fill.

Supports all div attributes.

PropType

SliderFill

A slider fill displays the selected region of the track.

PropType
ReactNode | function

SliderThumb

A slider thumb represents an individual value that the user can adjust within a slider track.

PropType
ReactNode | function
number
RefObject<HTMLInputElement | null>
boolean
Orientation

SliderOutput

A slider output displays the current value of a slider as text.

PropType
ReactNode | function

Last updated on 7/7/2026