Skip to content

ConfirmationModal

Official

A modal that asks the user to confirm an action. Use ConfirmationModal.addButton to add each option to the button row, and ConfirmationModal.addCancelButton for the dismissal button. Buttons auto-close the modal on click unless the handler returns truthy.

Import:

import { ConfirmationModal } from 'obsidian';

Signature:

export class ConfirmationModal extends Modal

Extends: Modal

Constructor

new ConfirmationModal(app: App)

Constructor.

To get the constructor instance, use getModalConstructor 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
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)
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
addCancelButton(text?) this
addCheckbox(label, cb) this
addClass(cls) this
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)
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: