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 | undefined)

Constructor.

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

Properties

PropertyTypeDescription
buttonContainerElHTMLElement | nullThe container element for action buttons, created lazily by Notice.addButton. null until then.
containerElHTMLElementThe container HTML element for the notice.
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.
setAutoHide(timeoutMilliseconds)thisSchedules the notice to auto-hide after the given duration, clearing any existing timer.
setMessage(message)thisChange the message of this notice.

Links to this page: