Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Notification

Essentially a Message with different styling.

Basic Usage

If you have fully registered the component library, you can use it in the following ways:

  • window.$notification;
  • Inside a Vue component: getCurrentInstance().appContext.config.globalProperties.PixeliumVue.notification;
  • Import from @pixelium/web-vue.

For on-demand import, you can also import Notification from @pixelium/web-vue/es.

Hide source code

Message Types

Notification has multiple types: 'normal' (default), 'info', 'success', 'warning', 'error', 'loading', 'sakura', 'notice'. Among them, 'normal' and 'sakura' do not display an icon by default.

Hide source code

Position

Notification can appear in four positions: top-left, top-right (default), bottom-left, bottom-right.

Hide source code

Closable

Set closable to make the Notification closable.

Hide source code

Duration

Set duration to control how long the Notification stays.

Hide source code

Notification Container

The NotificationBox component is the container for messages. The position where messages appear is determined by the container's placement. In notifications created functionally, all notifications with the same placement are child components of the same NotificationBox. We also provide an export of NotificationBox.

Notification count: 0
Hide source code

API

NotificationFunction

ts
export type NotificationFunction = {
	(options: ValidContent | NotificationOptions): NotificationReturn
} & {
	[key in NotificationOptions['type'] & string]: (
		options: Omit<NotificationOptions, 'type'> | string
	) => NotificationReturn
}
declare const notification: NotificationFunction

ValidContent, ValidVNodeContent

ts
export type ValidContent = string | ((...args: any[]) => VNode | string | JSX.Element | null | void)
export type ValidVNodeContent = (...args: any[]) => VNode | JSX.Element

NotificationOptions

AttributeTypeOptionalDefaultDescriptionVersion
titleValidContentTrueNotification title.0.2.0
contentValidContentTrueNotification content.0.2.0
iconValidVNodeContentTrueNotification icon.0.2.0
durationnumberTrue5000Duration (ms).0.2.0
type'info' | 'success' | 'warning' | 'error' | 'loading' | 'normal' | 'sakura' | 'notice'True'normal'Notification type.0.2.0
colorstringTrueCustom primary color, see Supported color parsing for details.0.2.0
closablebooleanTruefalseWhether the Notification can be closed.0.2.0
placement'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'True'top'Notification placement.0.0.2
rootstring | HTMLElementTrue'body'NotificationBox mount element.0.2.0

NotificationReturn

AttributeTypeOptionalDefaultDescriptionVersion
close() => voidFalseClose the current Notification.0.2.0
clear() => voidFalseClear all Notifications in the current NotificationBox.0.2.0
unmount() => voidFalseUnmount the current NotificationBox.0.2.0

NotificationBoxProps

AttributeTypeOptionalDefaultDescriptionVersion
notificationsNotificationProps[]TrueAll Notification entries in the current NotificationBox, requires v-model.0.2.0
placement'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'True'top'Notification placement.0.0.2
zIndexnumberTruez-index style of NotificationBox.0.2.0
rootstring | HTMLElementTrue'body'NotificationBox mount element.0.2.0

NotificationBoxEvents

EventParameterDescriptionVersion
update:notificationsvalue: NotificationProps[]v-model updates the notifications property.0.2.0
closeid: string | number | symbolCallback for closing a Notification.0.2.0

NotificationBoxExpose

AttributeTypeOptionalDefaultDescriptionVersion
close(id: number | string | symbol) => voidFalseClose the current Notification.0.2.0

NotificationProps

AttributeTypeOptionalDefaultDescriptionVersion
titleValidContentTrueNotification title.0.2.0
contentValidContentTrueNotification content.0.2.0
iconValidVNodeContentTrueNotification icon.0.2.0
durationnumberTrue5000Duration (ms).0.2.0
idnumber | string | symbolTrueUnique identifier, defaults to a random nanoid.0.2.0
type'info' | 'success' | 'warning' | 'error' | 'loading' | 'normal' | 'sakura' | 'notice'True'normal'Notification type.0.2.0
colorstringTrueCustom primary color, see Supported color parsing.0.2.0
closablebooleanTruefalseWhether the Notification can be closed.0.2.0
placement'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'True'top-right'The marker for where the Notification appears, affects the animation effect.0.2.0