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

PropertyTypeDescription
appAppThe Obsidian app instance.
(Inherited from Modal)
bgElHTMLElementBackground applied to application to dim it
(Inherited from Modal)
bgOpacitystringOpacity percentage of the background
(Inherited from Modal)
buttonContainerElHTMLElementContainer for the modal's button row.
buttonsConfirmationButton[]The buttons in the modal's button row.
containerElHTMLElementThe container HTML element for the modal.
(Inherited from Modal)
contentElHTMLElementThe HTML element that represents the content of the modal.
(Inherited from Modal)
dimBackgroundbooleanWhether the background is being dimmed
(Inherited from Modal)
hasInitialInputFocusbooleanWhether the modal focuses its first input when opened.
(Inherited from Modal)
headerElHTMLDivElementHeader element of the modal dialog.
(Inherited from Modal)
modalElHTMLElementThe HTML element that represents the modal.
(Inherited from Modal)
scopeScopeThe scope for the keymaps.
(Inherited from Modal)
selectionnull | WindowSelectionSelection logic handler
(Inherited from Modal)
shouldAnimatebooleanWhether the modal should animate
(Inherited from Modal)
shouldRestoreSelectionbooleanWhether the modal should restore the selection when it is opened or closed.
(Inherited from Modal)
titleElHTMLElementThe HTML element that represents the title of the modal.
(Inherited from Modal)
winnull | WindowReference to the global Window object.
(Inherited from Modal)

Methods

MethodReturnsDescription
addButton(cb)thisAdd a button to the modal's button row.
addCancelButton(text?)thisAdd a cancel button to the modal's button row.
addCheckbox(label, cb)thisAdd a checkbox below the message.
addClass(cls)thisAdd 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()voidClose the modal.
(Inherited from Modal)
getRootEl()HTMLElementGets the modal's root element.
(Inherited from Modal)
onClickOutside(evt)voidCloses the modal when a click occurs outside of it, unless the event was already handled.
(Inherited from Modal)
onClose()voidCalled when the modal is closed.
(Inherited from Modal)
onEscapeKey()voidOn escape key press close modal
(Inherited from Modal)
onOpen()Promise<void> | voidCalled when the modal is opened.
(Inherited from Modal)
onWindowClose()voidOn closing of the modal
(Inherited from Modal)
open()voidShow the modal on the the active window. On phones, the modal will animate on screen.
(Inherited from Modal)
setBackgroundOpacity(opacity)thisSet the background opacity of the dimmed background.
(Inherited from Modal)
setCloseCallback(callback)thisSet the callback to be called when the modal is closed.
(Inherited from Modal)
setContent(content)thisSet the content of the modal.
(Inherited from Modal)
setDimBackground(dim)thisSet whether the background should be dimmed.
(Inherited from Modal)
setTitle(title)thisSet the title of the modal.
(Inherited from Modal)

Links to this page: