Skip to content

Notice

Official

Notification component. Use to present timely, high-value information.

Import:

import { Notice } from 'obsidian';

Signature:

export class Notice

Constructor

new Notice(message: string | DocumentFragment, duration?: number)

Constructor.

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

Properties

PropertyTypeDescription
autoHidebooleanWhether an auto-hide is scheduled. When the pointer leaves a notice that has one, it is rescheduled for 1 second.
buttonContainerElHTMLElement | nullThe container element for action buttons, created lazily by Notice.addButton. null until then.
containerElHTMLElementThe container HTML element for the notice.
hiddenbooleanWhether Notice.hide has been called.
hoveredbooleanWhether the pointer is over the notice. A hovered notice is not auto-hidden.
messageElHTMLElementThe HTML element that represents the message of the notice.
noticeElHTMLElementThe HTML element that represents the notice.
timerIdnumberThe auto-hide timer handle, or -1 when no auto-hide is scheduled.
winWindowThe window the notice is shown in.

Methods

MethodReturnsDescription
addButton(buttonText, callback)thisAdds an action button to the notice.
hide()voidHide the notice.
isHidden()booleanCheck whether the notice is hidden, either by Notice.hide or because its window was closed.
setAutoHide(timeoutMilliseconds)thisSchedules the notice to auto-hide after the given duration, clearing any existing timer.
setMessage(message)thisChange the message of this notice.
tryHide()voidHide the notice unless the pointer is over it. Called when the auto-hide timer fires.

Links to this page: