Skip to content

Slider

Allows selecting a value within a fixed range by dragging a handle.

Basic Usage

The most fundamental way to use the Slider.

Default
Custom Initial Value
Disabled
Basic Usage

With Input

Use the show-input property to enable precise numerical input.

With Input
Current Value: 15
With Input

Vertical Mode

Set the vertical property to true to enable vertical mode. In vertical mode, the height property must be set.

Single: 30
Range: [ 20, 50 ]
Vertical Mode

Marks

Use the marks property to label ticks on the Slider.

Slider Marks
0°C
37°C
50%
100°C
Current Value: 37
Marks

Custom Slots

Customize the slider handle via the thumb slot and markers via the mark slot. Example below:

Slots allow you to fully customize the appearance of the Slider, such as the handle (Thumb) or scale markers (Mark).

Custom Handle
45
Custom Slots

Nuxt Usage

The Slider component fully supports Nuxt 3/4 SSR. When used in a Nuxt project, it is auto-imported.

Usage in Nuxt

SSR Considerations:

  • ✅ Basic sliding and range selection are fully supported.
  • ✅ Step and marks render correctly on the server side.
  • ✅ Vertical layout remains consistent during SSR.
  • ✅ Slots (thumb/mark) support SSR rendering.
  • ⚠️ Drag interaction and Tooltip visibility are only active after client-side hydration.

SSR Safety

The Slider component's style system is optimized for SSR, ensuring the runway and bar have correct visuals on initial load, eliminating jumps during hydration.

API

Props

NameDescriptionTypeDefault
model-value / v-modelBinding valuenumber | [number, number]0
minMinimum valuenumber0
maxMaximum valuenumber100
stepStep sizenumber1
sizeSlider size'large' | 'default' | 'small''default'
show-inputWhether to show an input box (only for non-range mode)booleanfalse
show-input-controlsWhether to show control buttons in the input boxbooleantrue
input-sizeSize of the input box'large' | 'default' | 'small''default'
show-stopsWhether to show discrete pointsbooleanfalse
show-tooltipWhether to show a tooltipbooleantrue
format-tooltipFormatter for the tooltip text(val: number) => string | number
disabledWhether to disable the sliderbooleanfalse
rangeWhether to enable range selectionbooleanfalse
verticalWhether to enable vertical modebooleanfalse
heightHeight in vertical modestring
labelScreen reader labelstring
debounceDebounce delay for input (ms)number300
tooltip-classCustom class name for the tooltipstring
placementTooltip placementstring'top'
marksMarks; keys must be numbers within range [min, max]object
validate-eventWhether to trigger form validation when value changesbooleantrue
range-start-labelCustom aria-label for the start of the rangestring
range-end-labelCustom aria-label for the end of the rangestring
button-classCustom class for the slider buttonstring
colorCustom theme colorstring

Events

NameDescriptionParameters
update:modelValueTriggers when the bound value changes(val: number | [number, number]) => void
changeTriggers when value changes (on mouse release or track click)(val: number | [number, number]) => void
inputTriggers in real-time as data changes(val: number | [number, number]) => void

Slots

NameDescriptionParameters
thumbCustom slider handle{ value: number }
markCustom tick text{ mark: any }
defaultBottom reserved slot

Theme Variables

Color variables are integrated with the global theme system and support dark mode:

VariableDescriptionDefault
--yh-slider-main-colorMain color (bar filling, handle border)var(--yh-color-primary)
--yh-slider-bg-colorSlider runway background colorvar(--yh-border-color-light)
--yh-slider-hover-bg-colorRunway background color on hovervar(--yh-border-color-dark)
--yh-slider-button-sizeHandle button size16px
--yh-slider-button-borderHandle button border width2px
--yh-slider-runway-heightRunway height (width if vertical)6px
--yh-slider-heightOverall component height (container)32px
--yh-slider-tooltip-bgTooltip background colorvar(--yh-bg-color-overlay-dark)
--yh-slider-tooltip-textTooltip text colorvar(--yh-text-color-primary-dark)
--yh-slider-mark-text-colorMark text colorvar(--yh-text-color-secondary)

Released under the MIT License.