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://github.com/mnaoumov/obsidian-dev-utils/releases/latest/download/styles.css.

Import:

import { NumberComponent } from 'obsidian-dev-utils/obsidian/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.

Methods

MethodReturnsDescription
empty()voidEmpties the component.
isEmpty()booleanChecks if the component is empty.
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.
setPlaceholderValue(placeholderValue)thisSets the placeholder value of the component.
(Inherited from TextBasedComponent)
setStep(step)thisSets the step value of the component.
(Inherited from TypedRangeTextComponent)
valueFromString(str)numberConverts a string to a number.

Links to this page: