VisorVisor
ComponentsForm

Slider

A draggable range input for selecting numeric values. Built on Radix UI.

Default

Range (Two Thumbs)

With Step

Disabled

Installation

npx visor add slider

This copies two files into your project:

  • components/ui/slider/slider.tsx — the component
  • components/ui/slider/slider.module.css — the styles

Usage

import { Slider } from '@/components/ui/slider/slider';

<Slider defaultValue={[50]} max={100} step={1} />

API Reference

SliderProps

PropTypeDefaultDescription
valuenumber[]Controlled value(s). Use an array for range sliders.
defaultValuenumber[]Default value(s) for uncontrolled usage.
minnumber0Minimum value.
maxnumber100Maximum value.
stepnumber1Step increment between values.
onValueChange(value: number[]) => voidCallback when the value changes.

Sub-components

Slider exports a single component that internally composes Radix UI primitives:

ComponentElementPurpose
Slider<span> (Radix Root)Root container managing value state and keyboard interaction
Slider.Track<span>Horizontal track representing the full range
Slider.Range<span>Filled portion of the track indicating the current value
Slider.Thumb<span>Draggable handle(s) with role="slider" for each value

Accessibility

  • Built on @radix-ui/react-slider with full WAI-ARIA slider semantics
  • Each thumb renders with role="slider", aria-valuemin, aria-valuemax, and aria-valuenow
  • Provide aria-label on <Slider> or use aria-labelledby pointing to a visible label
  • Keyboard: Arrow keys adjust value by step; Home/End jump to min/max; Page Up/Down adjust by larger increments
  • For range sliders, each thumb is independently focusable and operable