Skip to main content

Slider

Slider lets users select a value or range along a track. It supports discrete marks, formats for value labels, vertical orientation, RTL, and integrates with the sl styling system (our global styling prop).

Demo

Value: 40
0255075100

Variants

Range, marks & discrete

Range: 2070
0MidMax02040608010050

Vertical, inverted & RTL

Vertical
Inverted track
RTL

Styling with sl

Use design tokens with the sl prop to tweak spacing, colors, radii, and more.

Usage

import React from 'react';
import { Slider } from '@libdev-ui/base';

export default function Example() {
const [value, setValue] = React.useState<[number, number]>([25, 60]);
return (
<div style={{ display: 'grid', gap: 16 }}>
<Slider
value={value}
onChange={(_, v) => Array.isArray(v) && setValue(v)}
min={0}
max={100}
step={5}
marks={[{ value: 0, label: '0' }, { value: 50, label: 'Mid' }, { value: 100, label: 'Max' }]}
valueLabelDisplay="auto"
valueLabelFormat={(v) => `${v}%`}
size="md"
variant="filled"
color="primary"
thumbPulse
motionEnabled
ls={{ width: 460 }}
/>
</div>
);
}

Props

Slider

PropTypeDefaultDescription
valuenumber | [number, number]Controlled value; use an array for range
defaultValuenumber | [number, number]Uncontrolled initial value
minnumber0Minimum value
maxnumber100Maximum value
stepnumber | null1When null, thumbs snap only to marks
shiftStepnumber10PageUp/PageDown and Shift+Arrow step
disabledbooleanfalseDisable interactions
disableSwapbooleanfalsePrevent thumbs from swapping in range mode
size'sm' | 'md' | 'lg' | string'md'Visual size token
variant'filled' | 'outlined' | 'ghost' | string'filled'Visual variant
colortoken | string'primary'Color token or any CSS color
orientation'horizontal' | 'vertical''horizontal'Orientation of the component
track'normal' | 'inverted' | false'normal'Track presentation mode
isRtlbooleanfalseRTL rendering (temporary prop)
marksboolean | Array<{value:number,label?:React.ReactNode}>falseDiscrete marks
valueLabelDisplay'auto' | 'on' | 'off''off'When to display the value label
valueLabelFormat(value:number, index:number) => React.ReactNode | stringLabel formatter
getAriaLabel(index:number) => stringA11y label generator for thumbs
getAriaValueText(value:number, index:number) => stringA11y value text
namestringName of the hidden input(s) for forms
tabIndexnumberTab index for focusable elements
componentElementTypeRoot override
slotsPartial<Record<SlotName, ElementType>>Slot component overrides
slotPropsPartial<Record<SlotName, HTMLAttributes>>Props per slot
slSlPropSystem styling — tokens, responsive objects
lsCommonLayoutPropsLayout props applied to the root
classNamestringRoot className
styleCSSPropertiesInline styles
dir'ltr' | 'rtl'Direction override
motionEnabledbooleantrueEnables micro-animations (tooltip fade, track smoothness)
motionSpeed'slow' | 'normal' | 'fast''normal'Visual speed preset (reserved for fine tuning)
thumbPulsebooleanfalsePulse animation on active/hovered thumb

Notes

  • Set step={null} to restrict movement to marks.
  • In range mode, pass [minValue, maxValue] to value/defaultValue.
  • Use ls for layout (width/height/margins) and sl for design tokens and responsive styling.
  • RTL can be enabled via dir="rtl" per instance or globally in your app.