Skip to content

TelephoneComponent

A component that allows the user to enter a telephone number.

It looks like regular text component on desktop but changes keyboard to digits only on mobile.

You can add this component using SettingEx.addTelephone.

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 { TelephoneComponent } from 'obsidian-dev-utils/obsidian/setting-components/telephone-component';

Signature:

export class TelephoneComponent extends TypedTextComponent<string> implements TextBasedComponent<string>

Extends: TypedTextComponent<string>

Implements: TextBasedComponent<string>

Constructor

new TelephoneComponent(containerEl: HTMLElement)

Creates a new telephone component.

Properties

PropertyTypeDescription
inputElHTMLInputElementAn input element of the component.
(Inherited from TypedTextComponent)
textComponentTextComponentThe inner text component.
(Inherited from TypedTextComponent)

Methods

MethodReturnsDescription
empty()voidEmpties the component.
getValue()stringGets the value of the component.
(Inherited from TypedTextComponent)
isEmpty()booleanChecks if the component is empty.
onChange(callback)thisSets the callback function to be called when the component is changed.
(Inherited from TypedTextComponent)
onChanged()voidCalled when the component is changed.
(Inherited from TypedTextComponent)
setDisabled(disabled)thisSets the disabled state of the component.
(Inherited from TypedTextComponent)
setPlaceholderValue(placeholderValue)thisSets the placeholder value of the component.
setPlaceholderValue(placeholderValue)thisSets the placeholder value of the component.
(Inherited from TextBasedComponent)
setValue(value)thisSets the value of the component.
(Inherited from TypedTextComponent)
valueFromString(str)stringGets the value from a string.
valueToString(value)stringConverts a value to a string.
(Inherited from TypedTextComponent)

Links to this page: