UI.MD

Slider

A control for selecting a value or range from within a given range.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/slider.json

Usage

import { Slider } from "@/components/ui/slider"

Examples

Default

Range

API Reference

PropTypeDefaultDescription
defaultValuenumber[]-Initial value when uncontrolled. One thumb renders per entry, so [25, 75] creates a range slider.
valuenumber[]-Controlled value. Use with onValueChange.
onValueChange(value: number[]) => void-Called with the new value as a thumb is dragged.
onValueCommit(value: number[]) => void-Called once the user finishes an interaction, useful for skipping updates on every tick of a drag.
minnumber0The minimum value of the range.
maxnumber100The maximum value of the range.
stepnumber1The granularity each thumb snaps to.
minStepsBetweenThumbsnumber0Minimum gap (in steps) enforced between thumbs in a range slider.
orientation"horizontal" | "vertical""horizontal"Layout direction. Vertical sliders get an 11rem minimum height.
invertedbooleanfalseReverses the slider's direction so the range fills from the opposite end.
disabledbooleanfalseDisables interaction and dims the slider.
namestring-Name submitted with its owning form, via a hidden input per thumb.