Skip to content

Slider

Allows selecting a value within a fixed range by dragging one or two handles.

Basic Usage

The most common single-value slider usage.

Default
Custom Initial Value
Disabled
Basic Usage

With Input

Set show-input to display an input box for precise numeric editing. This mode is available in non-range mode only.

With Input
Current Value: 15
With Input

Vertical Mode

Set vertical to true to enable vertical mode. In vertical mode, height should also be provided.

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

Marks

Use marks to render labeled positions across the slider track.

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

Custom Slots

Use the thumb slot to customize the handle. The component also supports a mark slot for custom mark content.

Slots let you customize the slider thumb and marks without changing the core interaction behavior.

Custom Handle
45
Custom Slots

Use in Nuxt

YhSlider supports Nuxt SSR. Initial values, marks, and layout render on the server, while dragging and tooltip interaction continue on the client after hydration.

Use in Nuxt

API

Props

NameDescriptionTypeDefault
model-value / v-modelBound valuenumber | [number, number]0
minMinimum valuenumber0
maxMaximum valuenumber100
stepStep sizenumber1
show-inputWhether to show an input box in non-range modebooleanfalse
show-input-controlsWhether the input box shows control buttonsbooleantrue
sizeSlider size'' | 'large' | 'default' | 'small'''
input-sizeInput box size'' | 'large' | 'default' | 'small'''
show-stopsWhether discrete stops are shownbooleanfalse
show-tooltipWhether the tooltip is shown while interactingbooleantrue
format-tooltipTooltip formatter(val: number) => string | numberundefined
disabledWhether the slider is disabledbooleanfalse
rangeWhether range selection is enabledbooleanfalse
verticalWhether vertical mode is enabledbooleanfalse
heightHeight used in vertical modestring''
labelScreen reader labelstringundefined
debounceDebounce delay for input changes in millisecondsnumber300
tooltip-classCustom tooltip class namestringundefined
placementTooltip placement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end''top'
marksMark definitions keyed by numeric values within [min, max]Record<number, string | { style?: CSSProperties; label: string }>undefined
validate-eventWhether form validation is triggered when the value changesbooleantrue
range-start-labelCustom aria-label for the start handle in range modestringundefined
range-end-labelCustom aria-label for the end handle in range modestringundefined
button-classCustom class name applied to slider buttonsstringundefined
colorCustom main color for the active track and handlesstringundefined
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events

NameDescriptionParameters
update:modelValueTriggered when the bound value changes(val: number | [number, number]) => void
changeTriggered when the final value is committed(val: number | [number, number]) => void
inputTriggered continuously while the value changes(val: number | [number, number]) => void

Slots

NameDescriptionParameters
thumbCustom slider thumb{ value: number }
markCustom mark content{ mark: string }
defaultReserved bottom slot content-

Expose

NameDescriptionType
sliderRefRoot slider element refRef<HTMLElement | undefined>
firstValueCurrent primary handle valueRef<number>
secondValueCurrent secondary handle value in range modeRef<number>

Theme Variables

YhSlider supports themeOverrides. The component stylesheet directly consumes the following slider-specific CSS variables, and the color prop also writes the main active color variables at runtime.

VariableDescriptionDefault
--yh-slider-main-colorMain active colorvar(--yh-color-primary)
--yh-slider-main-color-rgbRGB value of the main active color64, 158, 255
--yh-slider-secondary-colorSecondary active color for gradients and range barsvar(--yh-color-primary)
--yh-slider-bg-colorRunway background colorvar(--yh-border-color-light)
--yh-slider-hover-bg-colorRunway hover background colorvar(--yh-border-color-dark)
--yh-slider-button-sizeThumb size16px
--yh-slider-button-borderThumb border width2px
--yh-slider-runway-heightRunway thickness6px
--yh-slider-transitionTransition tokenvar(--yh-transition-base)
--yh-slider-heightComponent height32px

Type Exports

NameDescription
YhSliderPropsComponent props type
YhSliderEmitsComponent emits type
YhSliderSlotsComponent slots type
YhSliderExposeComponent expose type
YhSliderInstanceComponent instance type

Released under the MIT License.