Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Slider

This component somehow reminds me of a sliding rheostat, and this piece of music. 😂

Basic Usage

Pass modelValue to enter controlled mode. If not passed or is undefined, it will be in uncontrolled mode, where you can pass the defaultValue prop as the default value.

Controlled

Uncontrolled

Hide source code

Range Selection

The range prop enables range selection.

Hide source code

Value Range, Step & Precision

min and max set the numerical range. step sets the step size; when it is 0, the step size is not limited.

The precision parameter controls the minimum precision of the numerical value. It takes an integer in [0, 100]; when it is null, the minimum precision is not limited.

Setting the precision parameter is primarily intended to handle unexpected approximate values resulting from precision loss in JS floating-point calculations.

Hide source code

Readonly & Disabled

readonly sets it to read-only, disabled sets it to disabled. The only difference between them is almost just the styling.

Hide source code

Marks

marks sets the marks on the slider. When step is set to 'mark', only values at the marks can be selected.

Hide source code

Label Rendering

The mark slot customizes the rendering of labels of marks.

Hide source code

Vertical Orientation

direction sets the orientation of the slider. When vertical, the height defaults to the container's height, but you can also set the height yourself.

Hide source code

Track Reversal

direction sets the orientation of the slider. When vertical, the height defaults to the container's height, but you can also set the height yourself.

Hide source code

Thumb Indicator

You can use the thumb, thumb-start, and thumb-end slots to customize the content inside the thumbs.

L
R
Hide source code

API

SliderProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValuenumber | [number, number] | nullTrueThe value of the slider (controlled mode), supports v-model.0.0.3
defaultValuenumber | [number, number] | nullTrueThe default value of the slider (uncontrolled mode).0.0.3
minnumberTrue0The minimum value of the slider (inclusive).0.0.3
maxnumberTrue100The maximum value of the slider (inclusive).0.0.3
rangebooleanTruefalseRange selection.0.0.3
disabledbooleanTruefalseDisabled state.0.0.3
readonlybooleanTruefalseRead-only state.0.0.3
stepnumber | 'mark'True1The step size of the values.0.0.3
marks(number | { value: number; label?: string })[]TrueMarks on the slider.0.0.3
direction'horizontal' | 'vertical'True'horizontal'The orientation of the slider.0.0.3
reversebooleanTruefalseWhether to reverse the track.0.0.3
precisionnumber | nullTrue80.0.3
tooltipbooleanTruetrueWhether to enable text tooltip.0.0.3
tooltipPropsOmit<TooltipProps, 'visible' | 'content'> & EmitEvent<TooltipEvents>TrueProps for the Tooltip component in single-value mode.0.0.3
tooltipStartPropsOmit<TooltipProps, 'visible' | 'content'> & EmitEvent<TooltipEvents>TrueProps for the first Tooltip component in range selection mode.0.0.3
tooltipEndPropsOmit<TooltipProps, 'visible' | 'content'> & EmitEvent<TooltipEvents>TrueProps for the second Tooltip component in range selection mode.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This also affects the property of the same name in data input components that are child components.0.1.0

SliderEvents

EventParameterDescriptionVersion
update:modelValuevalue: number | [number, number]Callback for updating modelValue.0.0.3
changevalue: number | [number, number]Callback for value change.0.0.3
dragStartevent: MouseEvent | TouchEventCallback for drag start.0.0.3
dragEndevent: MouseEvent | TouchEventCallback for drag end.0.0.3
markSelectvalue: number, event: MouseEventCallback for mark selection.0.0.3
focusevent: FocusEventCallback for slider focus.0.0.3
focusevent: FocusEventCallback for slider focus.0.0.3

SliderSlots

SlotParameterDescriptionVersion
markvalue: number, label: string | undefinedRendering of mark labels.0.0.3
thumbContent of the thumb in single-value mode.0.0.3
thumb-startContent of the first thumb in range selection mode.0.0.3
thumb-endContent of the second thumb in range selection mode.0.0.3
tooltip-contentvalue: numberContent of the text tooltip.0.0.3

EmitEvent

ts
export type EmitEvent<T extends Record<string, any>> = {
	[K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void
}