Skip to content

DateComponent

A component that displays and edits a date.

You can add this component using SettingEx.addDate.

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 { DateComponent } from '@mnaoumov/obsidian-lib/setting-components/date-component';

Signature:

export class DateComponent extends TypedRangeTextComponent<Date>

Extends: TypedRangeTextComponent<Date>

Constructor

new DateComponent(containerEl: HTMLElement)

Creates a new date component.

Properties

PropertyTypeDescription
inputElHTMLInputElementAn input element of the component.
(Inherited from TypedRangeTextComponent)
onChange(callback: (newValue: Date) => void) => thisSets a callback function to be called when the value of the component changes.
(Inherited from TypedRangeTextComponent)
textComponentTextComponentThe inner text component.
(Inherited from TypedRangeTextComponent)
validatorElValidatorElementA validator element of the component.
(Inherited from TypedRangeTextComponent)

Methods

MethodReturnsDescription
getValue()DateGets the value of the component.
(Inherited from TypedRangeTextComponent)
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)
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)DateConverts a string to a date.
valueToString(value)stringConverts a date to a string.

Links to this page: