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

Notification ​

Corner notifications with auto-close, independent stacks, action buttons and Chalk/OEM themes.

The default export is a component plugin; the named Notification export is the callable service. CommonUI or app.use(NfNotification) installs this.$openNotify. In setup, useNotification() inherits provider injections and locale and disposes notifications on unmount. createNotification(appContext) creates an app-scoped service. Direct Notification never implicitly binds the last installed app; pass appContext as its second argument when needed.

Basic usage and positions ​

Loading example…
Basic usage and positions

Notification types ​

Loading example…
Notification types

Cancel and confirm ​

Loading example…
Cancel and confirm

Text, HTML and VNode ​

Loading example…
Text, HTML and VNode

Component and default slot ​

Loading example…
Component and default slot

Interactive example ​

click: 0; cancel: 0; confirm: 0; close: 0

Installation ​

ts
import NfNotification, { Notification, useNotification, createNotification } from '@94ai-plus/nf-notification'
import '@94ai-plus/nf-theme-chalk/nf-notification.css'

app.use(NfNotification)
Notification.success({ title: 'Saved', message: 'Success' })
const notify = createNotification(app._context)
notify.info('App context')
// setup(): const notify = useNotification()

Options ​

AttributeDescriptionTypeAccepted valuesDefault
titleTitlestring—''
messageDescription textstring / VNode—''
dangerouslyUseHTMLStringWhether to render message as HTML; trusted content onlyboolean—false
typeTheme style; unsupported values are ignoredstringsuccess / warning / info / error''
iconClassCustom icon class; a valid type takes precedencestring—''
customClassCustom class namestring—''
durationDisplay duration in ms; 0 disables automatic closingnumber—4500
positionCustom popup positionstringtop-right / top-left / bottom-right / bottom-lefttop-right
showCloseWhether to show the close buttonboolean—true
onCloseClose callback, receiving the closed instance’s public handler(handler: NotificationHandler) => void——
onClickCallback when Notification is clicked() => void——
offsetOffset shared by simultaneous Notification instances; an additional 16px viewport margin appliesnumber—0
cancelButtonTextCancel button textstring—''
confirmButtonTextConfirm button textstring—''
onCancelCancel button callback; does not close the notification automatically() => void——
onConfirmConfirm button callback; does not close the notification automatically() => void——
zIndexStacking level; service calls increment from 3001number—Auto-incremented

Events ​

EventDescriptionPayload
clickCallback when Notification is clicked—
cancelCancel button callback; does not close the notification automatically—
confirmConfirm button callback; does not close the notification automatically—
closeEmitted on close(handler: NotificationHandler)
destroyEmitted after the leave transition—

Slots ​

SlotDescriptionPayload
defaultBody content; takes precedence over message—

Methods and handler ​

APIDescription
Notification(string / VNode / options, appContext?)Returns NotificationHandler
Notification.success / warning / info / error(options?)Type shortcuts; accept string, VNode or options
handler.close()Close the current Notification; repeated calls are harmless
Notification.close(id, onClose?)Close by id; identical callback deduplicated
Notification.closeAll()Close a snapshot of active notifications
createNotification(appContext) / useNotification()Context-aware scoped service

Migration notes ​

Preserves the 4500ms default, independent corner stacks, 16px edges/gaps, hover pause and full-duration restart on leave. Delete/Backspace pause; other keys restart; Escape closes notifications. Keyboard handling no longer creates duplicate timers or restarts while hovering. Height changes, resizing and middle-item removal trigger reflow.

Cancel/confirm only invoke callbacks, without automatically closing or triggering card onClick. Call handler.close() explicitly when needed. Recognized type icons take priority over iconClass; no type/iconClass means no icon. Titles and strings are escaped. HTML mode is only for trusted content. Slot-only content now renders without message. Business content/action labels are supplied by the caller; close aria-label supports eight languages.

close() is idempotent; close(id) really closes the DOM and releases timers/listeners/observers. onClose receives NotificationHandler (id, position, el/$el/dom, visible, closed, close), not Vue 2 private instance fields. SSR returns a closed no-op handler. Scoped close/closeAll only affect owned notifications; direct Notification.closeAll() affects all notifications on the page. Message and Notification keep separate registries. Notifications mount into body and follow root data-nf-theme; declarative components do not join service stacks.