Slider

A component that allows users to select a value from a range.

Installation

$ npx shadcn@latest add "/r/slider.json"

Usage

Examples

Sizes

The slider comes in three sizes: small, medium, and large.

Min, Max, and Step

You can define the range and the increment value of the slider.

Disabled State

The slider can be disabled to prevent user interaction.

Props

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"The size of the slider.
defaultValuenumber[]-The initial value of the slider.
valuenumber[]-The controlled value of the slider.
onValueChange(value: number[]) => void-Event handler called when the value changes.
minnumber0The minimum value of the slider.
maxnumber100The maximum value of the slider.
stepnumber1The step increment of the slider.
disabledbooleanfalseWhether the slider is disabled.
classNamestring-Additional CSS classes to apply to the slider.