Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Slider for React

A slider for selecting a value from a range.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/aria/slider.json

Anatomy

Slider
├── SliderLabel
├── SliderThumb
├── SliderValue
├── SliderTrack
├── SliderRange
├── SliderControl
├── SliderMarkerGroup
├── SliderMarker
└── SliderDraggingIndicator

Usage

import { Slider } from "@/components/ui/slider";
<Slider
  className="mx-auto w-full max-w-xs"
  defaultValue={[75]}
  max={100}
  step={1}
/>

Accessibility

KeyDescription
ArrowUp
Increase the value when orientation is "vertical".
ArrowDown
Decrease the value when orientation is "vertical".
ArrowLeft
Decrease the value when orientation is "horizontal".
ArrowRight
Increase the value when orientation is "horizontal".
PageUp
Increase the value.
PageDown
Decrease the value.
Home
Go to the start.
End
Go to the end.

Demos

Range

Use an array with two values for a range slider.

Multiple

Use an array with multiple values for multiple thumbs.

Vertical

Use orientation="vertical" for a vertical slider.

Controlled

Controlled slider with a live value readout.

Disabled

Use the disabled prop to disable the slider.

Rtl

Right-to-left slider. See the RTL configuration guide for document direction.

API Reference

Slider

PropType
AttributeType

SliderLabel

PropType
AttributeType

SliderValue

PropType
AttributeType