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

Property Type Description
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.
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.
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.

Links to this page: