Skip to content

PluginNoticeComponentShowNoticeOptions

Options for PluginNoticeComponent.showNotice.

Import:

import type { PluginNoticeComponentShowNoticeOptions } from 'obsidian-dev-utils/obsidian/components/plugin-notice-component';

Signature:

export interface PluginNoticeComponentShowNoticeOptions

Properties

PropertyTypeDescription
isPermanent?booleanWhether the notice should stay until it is replaced, the plugin is reloaded, or the user dismisses it.

A permanent notice is shown with an infinite duration and is not hidden when the component unloads, so it can communicate state that outlives the plugin (e.g. a cleanup that requires a reload). There is at most one permanent notice per plugin: it is hidden by the next PluginNoticeComponent.showNotice call and dismissed automatically the next time the component loads (i.e. when the plugin is re-enabled).
mode?PluginNoticeModeHow this notice relates to the plugin's current notice — see PluginNoticeMode.

A permanent notice cannot be PluginNoticeMode.Separate (it needs the shared slot it is tracked in), and a notice that does not hide on click must be PluginNoticeMode.Separate (so a later notice never silently replaces it); either contradiction throws.
shouldHideOnClick?booleanWhether clicking the notice hides it. When true (the default), the notice dismisses on click like a normal Obsidian notice. When false, the notice is hard to close: it does not dismiss on any stray click, and instead shows a close (X) button that hides it directly (see PluginNoticeComponentShowNoticeOptions.shouldShowCloseButton and PluginNoticeComponentShowNoticeOptions.onCloseClick).

A shouldHideOnClick: false notice is shown with an infinite duration and stands on its own (implies PluginNoticeMode.Separate), so a later notice never silently replaces it; passing any other PluginNoticeComponentShowNoticeOptions.mode together with shouldHideOnClick: false throws.
shouldShowCloseButton?booleanWhether the close (X) button is shown on a hard-to-close notice (PluginNoticeComponentShowNoticeOptions.shouldHideOnClick = false). When false, no close button is rendered and the notice can only be hidden programmatically. Ignored unless shouldHideOnClick is false.

Methods

MethodReturnsDescription
onCloseClick(this, event)Promisable<void>A callback invoked when the user clicks the close (X) button, before the notice is hidden. Call PluginNoticeCloseClickEvent.cancel on the event to cancel the close and keep the notice open — for example after your own confirmation declines. An async callback is awaited before the notice is hidden. Runs only when a close button is shown (both PluginNoticeComponentShowNoticeOptions.shouldHideOnClick = false and PluginNoticeComponentShowNoticeOptions.shouldShowCloseButton are set).
onHide(this, info)Promisable<void>A callback invoked when the notice is hidden — whether by the user closing it, by a later reusable notice replacing it, by its duration elapsing, or on component unload. It runs at most once per notice. The PluginNoticeHideInfo argument distinguishes a user close (the close button) from a programmatic hide. An async callback is run fire-and-forget (its rejection surfaces through the async-error pipeline).