Component guideEditable source

Slider

A numeric value or range adjusted with one or more thumbs.

Original component docs
On this page8 sectionsBack to top

Use Slider for an approximate numeric setting with a meaningful range. This wrapper takes arrays even for one thumb. For exact amounts, provide a synchronized numeric input in your application.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/slider.json

#Usage

"use client";
import { useState } from "react";
import { Slider } from "@/components/ui/slider";

export default function VolumeSetting() {
  const [volume, setVolume] = useState([50]);
  return (
    <div className="grid max-w-sm gap-3">
      <p>Volume: {volume[0]}%</p>
      <Slider
        value={volume}
        onValueChange={setVolume}
        min={0}
        max={100}
        step={5}
        getAriaLabel={() => "Volume"}
      />
    </div>
  );
}

#API reference

PropPurposeDefault
value / onValueChangeControlled numeric arrayUncontrolled
defaultValueInitial thumb values[min]
min / max / stepRange and step0 / 100 / 1
orientationHorizontal or vertical layouthorizontal
getAriaLabelName for each thumb indexUnset
disabledPrevent adjustmentfalse
minStepsBetweenValuesMinimum thumb separation in steps0
thumbCollisionBehaviorswap, push, or noneswap
onValueCommittedWork performed when an interaction commitsUnset
classNameString or function of the Base UI slider state—

Base UI owns pointer capture, keyboard stepping, value normalization, collision behavior, form integration, and commit events. The wrapper only composes its styled parts and labels; it does not simulate native events or maintain a second slider engine.

#Accessibility

Name each thumb, especially for minimum/maximum ranges. Connect a visible group title with aria-labelledby and name each thumb with getAriaLabel. Show values and units in text. Test arrows, Home, and End, and keep pointer targets usable. Run expensive work at the end of interaction rather than on every drag update.

#Examples

#Two thumbs

Loading preview...

#Vertical

Loading preview...

#Controlled

The visible title names the slider group, and each thumb has its own minimum or maximum label.

Loading preview...