Notice
Official
Notification component. Use to present timely, high-value information.
Import:
import { Notice } from 'obsidian';Signature:
export class NoticeConstructor
new Notice(message: string | DocumentFragment, duration?: number)Constructor.
To get the constructor instance, use getNoticeConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| autoHide | boolean | Whether an auto-hide is scheduled. When the pointer leaves a notice that has one, it is rescheduled for 1 second. | |
| buttonContainerEl | HTMLElement | null | The container element for action buttons, created lazily by Notice.addButton. null until then. | |
| containerEl | HTMLElement | The container HTML element for the notice. | |
| hidden | boolean | Whether Notice.hide has been called. | |
| hovered | boolean | Whether the pointer is over the notice. A hovered notice is not auto-hidden. | |
| messageEl | HTMLElement | The HTML element that represents the message of the notice. | |
| noticeEl | HTMLElement | The HTML element that represents the notice. | |
| timerId | number | The auto-hide timer handle, or -1 when no auto-hide is scheduled. | |
| win | Window | The window the notice is shown in. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addButton(buttonText, callback) | this | Adds an action button to the notice. | |
| hide() | void | Hide the notice. | |
| isHidden() | boolean | Check whether the notice is hidden, either by Notice.hide or because its window was closed. | |
| setAutoHide(timeoutMilliseconds) | this | Schedules the notice to auto-hide after the given duration, clearing any existing timer. | |
| setMessage(message) | this | Change the message of this notice. | |
| tryHide() | void | Hide the notice unless the pointer is over it. Called when the auto-hide timer fires. |
Links to this page: