View fulldotdev/ui on GitHub

Slider

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

Installation

npx shadcn@latest add @fulldev/slider

Usage

import { Slider } from "@/components/ui/slider"
<Slider defaultValue={33} max={100} step={1} />

A single number renders one thumb, a pair renders a range. Thumbs use thumbAlignment="edge" by default, so they stay within the track at the minimum and maximum. Use thumbAlignment="center" to center them over the track endpoints.

Range

Use an array with two values for a range slider.

Multiple Thumbs

The official example has three thumbs. The Astro slider supports at most two, so this example is in the React Slider docs only.

Vertical

Use orientation="vertical" for a vertical slider.

Controlled

Listen to the slider:change event on the root to read the value. Dispatch slider:set with { value } to set it.

Disabled

Use the disabled prop to disable the slider.

RTL

Set dir="rtl" on the slider or a parent element.

API Reference

Source: src/components/ui/slider

PropTypeDefault
defaultValuenumber | [number, number]min
minnumber0
maxnumber100
stepnumber1
largeStepnumberstep * 10
orientation"horizontal" | "vertical""horizontal"
thumbAlignment"center" | "edge" | "edge-client-only""edge"
disabledbooleanfalse

See the data-slot docs for events and keyboard behavior.