Overview
TheModal class creates a modal dialog that overlays the main application window. Modals are useful for displaying temporary content, forms, or prompts that require user attention.
Constructor
Reference to the Obsidian App instance
Properties
Reference to the App instance
Keyboard scope for the modal, used for handling hotkeys
The outer container element of the modal
The main modal element
Element containing the modal title
Element containing the modal content. Add your custom content here.
Whether to restore the previous text selection when the modal closes. Default is true.Since: 0.9.16
Methods
open()
Shows the modal on the active window. On mobile devices, the modal will animate onto the screen.close()
Hides and closes the modal.onOpen()
Override this method to perform setup when the modal is opened. This is where you should add content tocontentEl.
Promise<void> | void
onClose()
Override this method to perform cleanup when the modal is closed.setTitle()
Sets the title of the modal.The title text to display
this (for chaining)
setContent()
Sets the content of the modal.The content to display, either as a string or DocumentFragment
this (for chaining)
setCloseCallback()
Registers a callback to be called when the modal closes.Function to execute when the modal closes
this (for chaining)
Since: 1.10.0
Example
See Also
- SuggestModal - Modal with suggestion input
- FuzzySuggestModal - Modal with fuzzy search