For vue2 projects, use @94ai/common-ui
LLMs.md

Message ​

Success, warning, info and error notifications with auto-close, stacking and Chalk/OEM themes.

The default export is a component plugin; the callable service is the named Message export. Installing CommonUI or app.use(NfMessage) provides this.$openMessage for Options API. In setup, useMessage() inherits provider injections and locale and disposes its messages on unmount. Direct Message does not implicitly bind the last installed app; pass appContext as its second argument or use createMessage(appContext).

Basic usage and types ​

Loading example…
Basic usage and types

Manual close and stacking ​

Loading example…
Manual close and stacking

Text, HTML and VNode ​

Loading example…
Text, HTML and VNode

Center, offset and custom icon ​

Loading example…
Center, offset and custom icon

Component and default slot ​

Loading example…
Component and default slot

Interactive example ​

close: 0; last:

Installation ​

ts
import NfMessage, { Message, useMessage, createMessage } from '@94ai-plus/nf-message'
import '@94ai-plus/nf-theme-chalk/nf-message.css'

app.use(NfMessage)
Message.success('Saved')
const appMessage = createMessage(app._context)
appMessage.info('App context')
// setup(): const message = useMessage()

Options ​

AttributeDescriptionTypeAccepted valuesDefault
messageMessage textstring / VNode—''
typeTypestringsuccess / warning / info / errorinfo
iconClassCustom icon class, overriding the default type iconstring—''
dangerouslyUseHTMLStringWhether to render message as HTML; trusted content onlyboolean—false
customClassCustom class namestring—''
durationDisplay duration in ms; 0 disables automatic closingnumber—3000
showCloseWhether to show the close buttonboolean—false
centerWhether to center the textboolean—false
onCloseClose callback, receiving the closed instance’s public handler(handler: MessageHandler) => void——
offsetMessage offset from the viewport top, in pxnumber—20
zIndexStacking level; service calls increment from 3001number—Auto-incremented

Events ​

EventDescriptionPayload
closeEmitted on close(handler: MessageHandler)
destroyEmitted after the leave transition—

Slots ​

SlotDescriptionPayload
defaultBody content; takes precedence over message—

Methods and handler ​

APIDescription
Message(string / VNode / options, appContext?)Returns MessageHandler
Message.success / warning / info / error(options?)Type shortcuts; accepts string, VNode or options
handler.close()Close the current Message; repeated calls are harmless
Message.close(id, onClose?)Close by id; optional extra callback (same callback deduplicated)
Message.closeAll()Close a snapshot of active messages
createMessage(appContext) / useMessage()Context-aware scoped service

Migration notes ​

Preserves four types, 3000ms default, hover pause/full-duration restart, Escape closing all messages, and 8px stack spacing. The source default offset is 20px (legacy docs incorrectly said 100); explicit zero works. Height changes, window resizing and closing a middle item trigger reflow. Messages render into body and follow the root data-nf-theme. Services share the page stack.

close() is idempotent. close(id) now really closes the DOM message. Timers, listeners and observers are cleaned up. onClose receives MessageHandler (id, el/$el, visible, closed, close), not Vue 2 private instance fields. SSR returns a closed no-op handler. App-scoped close/closeAll only affect that service; direct Message.closeAll() affects the page. Snapshot closing does not close new messages created in callbacks.

Strings are escaped. dangerouslyUseHTMLString is for trusted HTML only, never user input. The default slot overrides message. iconClass replaces the default SVG and removes the type modifier. The keyboard-accessible close button has a translated aria-label; business content is not auto-translated. Declarative components use fixed positioning but do not join the service stack. Use the service for multiple messages.