Skip to content

Setting

Official

A setting.

Import:

import { Setting } from 'obsidian';

Signature:

export class Setting

Constructor

new Setting(containerEl: HTMLElement)

Constructor.

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

Properties

PropertyTypeDescription
componentsBaseComponent[]The components for the setting.
controlElHTMLElementThe HTML element for the control.
descElHTMLElementThe HTML element for the description.
errorElHTMLElement | nullError message element shown below the input. Created by setErrorMessage.
infoElHTMLElementThe HTML element for the info.
nameElHTMLElementThe HTML element for the name.
settingElHTMLElementThe HTML element for the setting.

Methods

MethodReturnsDescription
addButton(cb)thisAdd a button to the setting.
addColorPicker(cb)thisAdd a color picker component to the setting.
addComponent(cb)thisAdd a component to the setting.
addDisplayValue(cb)thisAdd a read-only display value to the row. On a navigable row, this surfaces the value edited on the page the row opens, so the user can see it without opening that page.
addDropdown(cb)thisAdd a dropdown component to the setting.
addExtraButton(cb)thisAdd an extra button to the setting.
addMomentFormat(cb)thisAdd a moment format component to the setting.
addProgressBar(cb)thisAdd a progress bar component to the setting.
addSearch(cb)thisAdd a search component to the setting.
addSlider(cb)thisAdd a slider component to the setting.
addText(cb)thisAdd a text component to the setting.
addTextArea(cb)thisAdd a text area component to the setting.
addToggle(cb)thisAdd a toggle to the setting.
clear()thisClear the setting.
setAction(callback)thisMakes the whole setting row act as a button, invoking the callback when clicked.
setClass(cls)thisSet the class of the setting.
setDesc(desc)thisSet the description of the setting.
setDisabled(disabled)thisDisable the setting.
setErrorMessage(message)thisShow a persistent validation error message below the setting. Pass an empty string or null to clear it. Adds the is-invalid class to the setting row when a message is present.
setHeading()thisMake the setting a heading.
setName(name)this
setName(name)thisSet the name of the setting.
setNavigable(callback)thisMakes the setting row navigable (adds a chevron and click handling).
setNoInfo()thisHide the info section of the setting.
setTooltip(tooltip, options?)thisSet the tooltip of the setting.
setVisibility(visible)thisShows/hides the setting.
then(cb)thisFacilitates chaining.

Links to this page: