Skip to content

NumberComponent

A component that displays and edits a number.

You can add this component using SettingEx.addNumber.

In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.

Alternatively, you can copy styles from https://unpkg.com/@mnaoumov/obsidian-lib/dist/styles.css.

Import:

import { NumberComponent } from '@mnaoumov/obsidian-lib/setting-components/number-component';

Signature:

export class NumberComponent extends TypedRangeTextComponent<number> implements TextBasedComponent<number>

Extends: TypedRangeTextComponent<number>

Implements: TextBasedComponent<number>

Constructor

new NumberComponent(containerEl: HTMLElement)

Creates a new number component.

Properties

PropertyTypeDescription
empty() => voidEmpties the component.
(Inherited from TextBasedComponent)
inputElHTMLInputElementAn input element of the component.
(Inherited from TypedRangeTextComponent)
isEmpty() => booleanChecks if the component is empty.
(Inherited from TextBasedComponent)
onChange(callback: (newValue: number) => void) => thisSets a callback function to be called when the value of the component changes.
(Inherited from TypedRangeTextComponent)
setPlaceholderValue(placeholderValue: number) => thisSets the placeholder value of the component.
(Inherited from TextBasedComponent)
textComponentTextComponentThe inner text component.
(Inherited from TypedRangeTextComponent)
validatorElValidatorElementA validator element of the component.
(Inherited from TypedRangeTextComponent)

Methods

MethodReturnsDescription
empty()voidEmpties the component.
getValue()numberGets the value of the component.
(Inherited from TypedRangeTextComponent)
isEmpty()booleanChecks if the component is empty.
onChange(callback)thisSets the callback function to be called when the component is changed.
(Inherited from TypedRangeTextComponent)
onChanged()voidCalled when the component is changed.
(Inherited from TypedRangeTextComponent)
setDisabled(isDisabled)thisSets the disabled state of the component.
(Inherited from TypedRangeTextComponent)
setMax(max)thisSets the maximum value of the component.
(Inherited from TypedRangeTextComponent)
setMin(min)thisSets the minimum value of the component.
(Inherited from TypedRangeTextComponent)
setPlaceholder(placeholder)thisSets the placeholder of the component.
setPlaceholderValue(placeholderValue)thisSets the placeholder value of the component.
setStep(step)thisSets the step value of the component.
(Inherited from TypedRangeTextComponent)
setValue(value)thisSets the value of the component.
(Inherited from TypedRangeTextComponent)
valueFromString($string)numberConverts a string to a number.
valueToString(value)stringConverts a value to a string.
(Inherited from TypedRangeTextComponent)

Links to this page: