Skip to content

PluginSettingTab

Official

Provides a unified interface for users to configure the plugin.

Import:

import { PluginSettingTab } from 'obsidian';

Signature:

export class PluginSettingTab extends SettingTab

Extends: SettingTab

Constructor

new PluginSettingTab(app: App, plugin: Plugin)

Constructor.

To extract the constructor type, use ExtractConstructor<PluginSettingTab>.

Properties

PropertyTypeDescription
appAppReference to the app instance.
(Inherited from SettingTab)
containerElHTMLElementHTML element for the setting tab content.
(Inherited from SettingTab)
iconIconNameThe icon to display in the settings sidebar.
(Inherited from SettingTab)
idstringUnique ID of the tab.
(Inherited from SettingTab)
installedPluginsEl?HTMLElementReference to installed plugins element.

Tab is the community plugins tab.
(Inherited from SettingTab)
namestringSidebar name of the tab.
(Inherited from SettingTab)
navElHTMLElementSidebar navigation element of the tab.
(Inherited from SettingTab)
plugin?PluginReference to the plugin that initialized the tab.

Tab is a plugin tab.
(Inherited from SettingTab)
renderedItemsunknown[]The rendered setting items (and groups) currently shown in the tab.
(Inherited from SettingTab)
settingSettingReference to the settings modal.
(Inherited from SettingTab)
settingItemsSettingDefinitionItem[]Nested setting definitions as returned by getSettingDefinitions. Populated by update.
(Inherited from SettingTab)

Methods

MethodReturnsDescription
display()voidOverride to render the tab imperatively.

Not called when getSettingDefinitions returns a non-empty array; the tab is rendered declaratively from those definitions instead. Only implement display() as a fallback for plugins that need to support Obsidian versions older than 1.13.0.
(Inherited from SettingTab)
getControlBinding(configKey)unknownBuilds a two-way binding (current value plus an onChange persister) for a control key.
(Inherited from SettingTab)
getControlValue(key)unknownReads from this.plugin.settings. Override to read from a different data source.
getDefinitionForElement(el)unknownFinds the setting definition rendered to the given element.
(Inherited from SettingTab)
getElementForDefinition(definition)HTMLElement | undefinedFinds the rendered element for a setting definition.
(Inherited from SettingTab)
getSettingDefinitions()SettingDefinitionItem[]Return setting definitions for this tab.
hide()voidHides the contents of the setting tab. Any registered components should be unloaded when the view is hidden. Override this if you need to perform additional cleanup.
(Inherited from SettingTab)
refreshDomState()voidRe-evaluate every visible and disabled predicate against the current state and apply the result to the rendered DOM. Call this from a render callback's onChange (or any other imperative path) after mutating state that other settings' predicates depend on.

Cheap: toggles CSS state in place, no re-render. For changes that affect the structure of the definitions themselves (added or removed items), call update instead.
(Inherited from SettingTab)
renderTab()voidRe-renders the tab's already-built setting items, or displays the tab if none exist yet.
(Inherited from SettingTab)
setControlValue(key, value)void | Promise<void>Mutates and persists this.plugin.settings. Override to write to a different data source.
update()voidStores the result of getSettingDefinitions for rendering and search indexing. Called by addSettingTab() and by dynamic tabs when their data changes.
(Inherited from SettingTab)