Skip to content

Slider ​

An input where the user selects a value from within a given range. Drag the thumb, tap the track, or use the arrow keys when focused.

Usage ​

Approximate web preview — the HarmonyOS rendering is the reference.

Range ​

Two thumbs that never cross; the value bubble shows while dragging.

Approximate web preview — the HarmonyOS rendering is the reference.

Ticks, marks & tooltip ​

Approximate web preview — the HarmonyOS rendering is the reference.

Vertical ​

orientation: 'vertical' with a length; the value grows upward.

Approximate web preview — the HarmonyOS rendering is the reference.

API ​

Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.

SSlider ​

shadcn-vue Slider, custom drawn: h-1.5 rounded-full bg-muted track, bg-primary range, size-4 rounded-full border border-primary bg-background shadow-sm thumb with a ring-4 ring-ring/50 on hover / drag. Drag a thumb or tap the track; arrow keys step when focused.

Variants:

  • range: pass values / defaultValues with two numbers for two thumbs (onValuesChange); thumbs never cross.
  • ticks (a dot per step) and marks (labelled values under / beside the track, via formatValue).
  • orientation: 'vertical' (value grows upward; give it a length, default 160vp).
  • keyboard: arrows step the value (in range mode, the thumb touched last).
  • tooltip: 'active' shows the value above the thumb while dragging / hovering / focused, 'always' keeps it.
PropTypeDefaultDescription
value!!number | undefinedundefinedControlled value (use with !!). Leave undefined for uncontrolled.
defaultValuenumber0
values!!number[] | undefinedundefinedControlled two-thumb range [low, high] (use with !!).
defaultValuesnumber[][]Uncontrolled initial range; two numbers turn on range mode.
minnumber0
maxnumber100
stepnumber1
disabledbooleanfalse
orientationSliderOrientation
SliderOrientation = 'horizontal' | 'vertical'
'horizontal'
lengthnumber160Length of a vertical slider (vp).
ticksbooleanfalseA dot at every step (up to 41 steps).
marksnumber[][]Labelled values along the track.
tooltipSliderTooltip
SliderTooltip = 'none' | 'active' | 'always'
'none'
formatValue(v: number) => string(v: number): string => `${v}`Text of tooltips and marks.
labelstring | undefinedundefinedAccessible name.
EventTypeDefaultDescription
onValueChange(v: number) => void() => { }
onValueCommit(v: number) => void() => { }Fired once when a drag / tap / key interaction ends.
onValuesChange(v: number[]) => void() => { }
onValuesCommit(v: number[]) => void() => { }Range mode: fired once when an interaction ends.

MIT Licensed