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

Property Type Description
components BaseComponent[] The components for the setting.
controlEl HTMLElement The HTML element for the control.
descEl HTMLElement The HTML element for the description.
errorEl HTMLElement | null Error message element shown below the input. Created by setErrorMessage.
infoEl HTMLElement The HTML element for the info.
nameEl HTMLElement The HTML element for the name.
settingEl HTMLElement The HTML element for the setting.

Methods

Method Returns Description
addButton(cb) this Add a button to the setting.
addColorPicker(cb) this Add a color picker component to the setting.
addComponent(cb) this Add a component to the setting.
addDisplayValue(cb) this Add 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) this Add a dropdown component to the setting.
addExtraButton(cb) this Add an extra button to the setting.
addMomentFormat(cb) this Add a moment format component to the setting.
addProgressBar(cb) this Add a progress bar component to the setting.
addSearch(cb) this Add a search component to the setting.
addSlider(cb) this Add a slider component to the setting.
addText(cb) this Add a text component to the setting.
addTextArea(cb) this Add a text area component to the setting.
addToggle(cb) this Add a toggle to the setting.
clear() this Clear the setting.
setAction(callback) this Makes the whole setting row act as a button, invoking the callback when clicked.
setClass(cls) this Set the class of the setting.
setDesc(desc) this Set the description of the setting.
setDisabled(disabled) this Disable the setting.
setErrorMessage(message) this Show 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() this Make the setting a heading.
setName(name) this
setName(name) this Set the name of the setting.
setNavigable(callback) this Makes the setting row navigable (adds a chevron and click handling).
setNoInfo() this Hide the info section of the setting.
setTooltip(tooltip, options?) this Set the tooltip of the setting.
setVisibility(visible) this Shows/hides the setting.
then(cb) this Facilitates chaining.

Links to this page: