Skip to content

ConfirmationModal

Official

A modal with a configurable button row used to confirm a destructive or otherwise irreversible action.

Import:

import { ConfirmationModal } from 'obsidian';

Signature:

export class ConfirmationModal extends Modal

Extends: Modal

Constructor

new ConfirmationModal(app: App)

Creates a new instance of ConfirmationModal.

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

Properties

Property Type Description
app App The Obsidian app instance.
(Inherited from Modal)
bgEl HTMLElement Background applied to application to dim it
(Inherited from Modal)
bgOpacity string Opacity percentage of the background
(Inherited from Modal)
buttonContainerEl HTMLElement Container for the modal's button row.
buttons ConfirmationButton[] The buttons in the modal's button row.
containerEl HTMLElement The container HTML element for the modal.
(Inherited from Modal)
contentEl HTMLElement The HTML element that represents the content of the modal.
(Inherited from Modal)
dimBackground boolean Whether the background is being dimmed
(Inherited from Modal)
hasInitialInputFocus boolean Whether the modal focuses its first input when opened.
(Inherited from Modal)
headerEl HTMLDivElement Header element of the modal dialog.
(Inherited from Modal)
modalEl HTMLElement The HTML element that represents the modal.
(Inherited from Modal)
scope Scope The scope for the keymaps.
(Inherited from Modal)
selection null | WindowSelection Selection logic handler
(Inherited from Modal)
shouldAnimate boolean Whether the modal should animate
(Inherited from Modal)
shouldRestoreSelection boolean Whether the modal should restore the selection when it is opened or closed.
(Inherited from Modal)
titleEl HTMLElement The HTML element that represents the title of the modal.
(Inherited from Modal)
win null | Window Reference to the global Window object.
(Inherited from Modal)

Methods

Method Returns Description
addButton(cb) this Add a button to the modal's button row.
addCancelButton(text?) this Add a cancel button to the modal's button row.
addCheckbox(label, cb) this Add a checkbox below the message.
addClass(cls) this Add a CSS class to the modal element.
animateClose() Promise<void> Performed when animation is complete
(Inherited from Modal)
animateOpen() Promise<void> Performed when animation is started
(Inherited from Modal)
close() void Close the modal.
(Inherited from Modal)
getRootEl() HTMLElement Gets the modal's root element.
(Inherited from Modal)
onClickOutside(evt) void Closes the modal when a click occurs outside of it, unless the event was already handled.
(Inherited from Modal)
onClose() void Called when the modal is closed.
(Inherited from Modal)
onEscapeKey() void On escape key press close modal
(Inherited from Modal)
onOpen() Promise<void> | void Called when the modal is opened.
(Inherited from Modal)
onWindowClose() void On closing of the modal
(Inherited from Modal)
open() void Show the modal on the the active window. On phones, the modal will animate on screen.
(Inherited from Modal)
setBackgroundOpacity(opacity) this Set the background opacity of the dimmed background.
(Inherited from Modal)
setCloseCallback(callback) this Set the callback to be called when the modal is closed.
(Inherited from Modal)
setContent(content) this Set the content of the modal.
(Inherited from Modal)
setDimBackground(dim) this Set whether the background should be dimmed.
(Inherited from Modal)
setTitle(title) this Set the title of the modal.
(Inherited from Modal)

Links to this page: