Slider

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

Installation

pnpm dlx cubix@latest add slider --base radix

Usage

Import
import { Slider } from "@/components/cubix/slider"
Example
<Slider defaultValue={[33]} max={100} step={1} />

Range

Use an array with two values for a range slider.

Multiple Thumbs

Use an array with multiple values for multiple thumbs.

Vertical

Use orientation="vertical" for a vertical slider.

Controlled

0.3, 0.7

Disabled

Use the disabled prop to disable the slider.

RTL

Wrap the slider in a container with dir="rtl" to mirror direction.

API Reference

See also the Base UI Slider documentation for primitive props.

Slider

PropTypeDefaultDescription
defaultValuenumber | number[]-Uncontrolled initial value. Use a single-item array for one thumb, or multiple values for a range.
valuenumber | number[]-Controlled value. Thumb count matches the array length.
onValueChange(value: number | number[], eventDetails?) => void-Called while the value changes (for example during drag).
onValueCommitted(value: number | number[], eventDetails?) => void-Called when a change is committed (Base UI). Radix uses onValueCommit.
minnumber0Minimum allowed value.
maxnumber100Maximum allowed value.
stepnumber1Step increment when adjusting the value.
orientation"horizontal" | "vertical""horizontal"Layout orientation of the slider.
disabledbooleanfalseWhen true, interaction is disabled.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).