NimUI
ComponentsForms

Slider

A slider input for selecting a value or range within a bounded interval

The Slider component lets users select a single value or a range from a bounded interval. Built on Radix UI Slider with OKLCH-themed tokens, it supports single/range modes, keyboard navigation, and vertical orientation.

Import

import { Slider } from '@nim-ui/components';

Basic Usage

Single Value
Code
<Slider defaultValue={[50]} min={0} max={100} step={1} />

Range Slider

Pass two values in defaultValue to enable range selection:

Range Selection
Code
<Slider defaultValue={[20, 80]} min={0} max={100} step={5} />

Sizes

Size Variants
Code
<Slider defaultValue={[50]} size="sm" />
<Slider defaultValue={[50]} size="md" />
<Slider defaultValue={[50]} size="lg" />

Controlled

const [value, setValue] = useState([30]);

return (
  <Slider
    value={value}
    onValueChange={setValue}
    min={0}
    max={100}
  />
);

Vertical

<Slider
  defaultValue={[50]}
  orientation="vertical"
  className="h-32"
/>

Props

NameTypeDefaultDescription
valuenumber[]-Controlled value(s). Provide [value] for single, [min, max] for range
defaultValuenumber[]-Uncontrolled initial value
onValueChange(value: number[]) => void-Callback fired when the value changes
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step increment
size'sm' | 'md' | 'lg''md'Size variant for track and thumb
orientation'horizontal' | 'vertical''horizontal'Slider orientation
disabledbooleanfalseDisable the slider

Accessibility

  • Thumbs have role="slider" with aria-valuemin, aria-valuemax, aria-valuenow
  • Range sliders label thumbs as "Minimum value" and "Maximum value" by default
  • Override with the standard aria-label prop on the root when you need a custom label like "Volume"
  • Full keyboard support: Arrow keys, Page Up/Down, Home/End
  • No motion to reduce: the thumb tracks the pointer directly and its only transition is a colour crossfade, so there is nothing for prefers-reduced-motion to switch off

Keyboard Support

KeyAction
Arrow Right / UpIncrease value by one step
Arrow Left / DownDecrease value by one step
Page UpIncrease by larger step
Page DownDecrease by larger step
HomeGo to minimum
EndGo to maximum

On this page