Skip to content

SearchComponent

Official

A search component.

Import:

import { SearchComponent } from 'obsidian';

Signature:

export class SearchComponent extends AbstractTextComponent<HTMLInputElement>

Extends: AbstractTextComponent<HTMLInputElement>

Constructor

new SearchComponent(containerEl: HTMLElement)

Constructor.

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

Properties

PropertyTypeDescription
clearButtonElHTMLElementThe HTML element for the clear button.
containerElHTMLElementThe containing element for the component's clearButtonEl and inputEl.
inputElHTMLInputElementThe input element.
(Inherited from AbstractTextComponent)

Methods

MethodReturnsDescription
addRightDecorator(decoratorFn)thisAdds a decorator to the right side of the search component.
autoSelect()thisSelects the input's text when it receives focus.
changeCallback(value)voidThe function that's called after changing the value of the component.
(Inherited from AbstractTextComponent)
getValue()stringGets the value of the input element.
(Inherited from AbstractTextComponent)
onChange(callback)thisSets the callback to handle when the value of the input element changes.
(Inherited from AbstractTextComponent)
onChanged()voidCalled when the search component's value changes.
registerOptionListener(listeners, key)thisRegister an option listener.
(Inherited from AbstractTextComponent)
setClass(cls)thisAdds a class to the search component.
setDisabled(disabled)thisSets the disabled state of the input element.
(Inherited from AbstractTextComponent)
setPlaceholder(placeholder)thisSets the placeholder of the input element.
(Inherited from AbstractTextComponent)
setValue(value)thisSets the value of the input element.
(Inherited from AbstractTextComponent)

Links to this page: