Skip to content

TagListComponent

A ListComponent of tags, stored without the # and shown with it. The add row suggests the vault’s tags, and a typed tag is refused unless it is a valid Obsidian tag: letters, digits, _, - and /, not digits only.

You can add this component using SettingEx.addTagList.

Import:

import { TagListComponent } from '@mnaoumov/obsidian-lib/setting-components/tag-list-component';

Signature:

export class TagListComponent extends ListComponent

Extends: ListComponent

Constructor

new TagListComponent(containerEl: HTMLElement, app: App)

Creates a new tag list component.

Properties

PropertyTypeDescription
listElHTMLElementThe element holding one row per item.
(Inherited from ListComponent)
newItemButtonExtraButtonComponentThe button that adds the typed item.
(Inherited from ListComponent)
newItemInputElHTMLInputElementThe input the next item is typed into.
(Inherited from ListComponent)
onChange(callback: (newValue: readonly string[]) => void) => thisSets a callback function to be called when the value of the component changes.
(Inherited from ListComponent)
suggestTagInputSuggestThe tag suggest attached to ListComponent.newItemInputEl.

Methods

MethodReturnsDescription
addTypedItem()booleanAdds the text typed into ListComponent.newItemInputEl, when it normalizes to an item not yet in the list, and clears the input.
(Inherited from ListComponent)
formatItem(item)stringShows a tag with its #.
getValue()readonly string[]Gets the items.
(Inherited from ListComponent)
normalizeItem(text)null | stringStrips the # from a typed tag and validates it.
onChange(callback)thisSets the callback to be called when the user adds, moves or removes an item.
(Inherited from ListComponent)
setDisabled(isDisabled)thisSets the disabled state of the component.
(Inherited from ListComponent)
setPlaceholder(placeholder)thisSets the placeholder of ListComponent.newItemInputEl.
(Inherited from ListComponent)
setValue(value)thisSets the items.
(Inherited from ListComponent)

Links to this page: