Slider

A native range input for a value between two bounds.

Overview

Slider is an input with type="range". The browser supplies the keyboard and the value. Name it with aria-label or a Label.

Preview

0

Customize

Default Value
0
Min
0
Max
100
Step
1

Installation

Add the component with the CLI. It copies the files in and installs anything they depend on.

npx vinyaas add slider

Usage

import { Slider } from "@/components/ui/slider"; export function Volume() { return <Slider aria-label="Volume" defaultValue={40} />; }

Examples

Volume

A labelled range for a setting with a known minimum and maximum.

Bounded step

min, max, and step stay on the native range input.

Range

Two native range inputs share one track. The selected interval uses the foreground token. The rest of the track stays muted.

In practice

Playback settings stack labelled sliders for volume, brightness, and text size. Apply saves the values.

40%
70%
16 px

API

Other attributes for the underlying element are passed through.

NameTypeDefaultDescription
valuenumber—Controlled value. Omit it to use defaultValue.
defaultValuenumber—Initial value for an uncontrolled slider.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Step between values.
onValueChange(value: number) => void—Called with the numeric value when the slider moves.
classNamestring—Merged onto the range input with cn.

Accessibility

The control is a native slider. Keyboard users change it with the arrow keys. Give it a name through a label or aria-label.