Skip to content

SliderComponent

Official

A slider component.

Import:

import { SliderComponent } from 'obsidian';

Signature:

export class SliderComponent extends ValueComponent<number>

Extends: ValueComponent<number>

Constructor

new SliderComponent(containerEl: HTMLElement)

Constructor.

To get the constructor instance, use getSliderComponentConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
sliderElHTMLInputElementThe HTML element that represents the slider.

Methods

MethodReturnsDescription
changeCallback(value)voidThe function that's called after changing the value of the component.
getValue()numberGet the value of the slider.
getValuePretty()stringGet the pretty value of the slider.
onChange(callback)thisSet the callback to be called when the slider value changes.
registerOptionListener(listeners, key)thisRegister an option listener.
(Inherited from ValueComponent)
setDisabled(disabled)thisDisable the slider.
setDisplayFormat(format)thisSet a custom formatter for the value shown inline next to the slider.
setDynamicTooltip()thisSet the dynamic tooltip of the slider.
setInstant(instant)thisSet whether or not the value should get updated while the slider is dragging.
setLimits(min, max, step)thisSet the limits of the slider.
setValue(value)thisSet the value of the slider.
setValue(value)thisSet the value of the component.
(Inherited from ValueComponent)
showTooltip()voidShows the slider's value tooltip.
updateDisplay()voidUpdates the displayed value text of the slider.

Links to this page: