Skip to content

Frontend Messages & Modals

DANGER

Exposes public notification components that can be called from anywhere in the frontend, for example:

  1. Called inside app.js
  2. Called in custom pages using parent.msg.xxx
  3. Called in the return JS of custom buttons
  4. Called when erupt-websocket pushes a message

INFO

Note: Supported since 1.12.15+

Global Message Component

javascript
window.msg.info('This is a normal message');
window.msg.success('This is a normal message');
window.msg.error('This is a normal message');
window.msg.warning('This is a normal message');

// loading
let loading = window.msg.loading('This is a normal message', { nzDuration: 2500 });
// Manually dismiss the loading message
window.msg.remove(loading.messageId);
javascript
window.modal.info({
  nzTitle: 'This is a notification message',
  nzContent: '<p>some messages...some messages...</p>',
  nzOnOk: () => console.log('Info OK')
})
window.modal.success({
  nzTitle: 'This is a notification message',
  nzContent: '<p>some messages...some messages...</p>',
  nzOnOk: () => console.log('Info OK')
})
window.modal.error({
  nzTitle: 'This is a notification message',
  nzContent: '<p>some messages...some messages...</p>',
  nzOnOk: () => console.log('Info OK')
})
window.modal.warning({
  nzTitle: 'This is a notification message',
  nzContent: '<p>some messages...some messages...</p>',
  nzOnOk: () => console.log('Info OK')
})
window.modal.confirm({
  nzTitle: 'Are you sure delete this task?',
  nzContent: '<b style="color: red;">Some descriptions</b>',
  nzOkText: 'Yes',
  nzOkType: 'primary',
  nzOkDanger: true,
  nzOnOk: () => console.log('OK'),
  nzCancelText: 'No',
  nzOnCancel: () => console.log('Cancel')
})

// Close all modals
window.modal.closeAll();

Notification Component

javascript
window.notify.blank('title', 'content', [options]) // Notification without icon
window.notify.success('title', 'content', {
  nzPlacement: 'bottom'
})
window.notify.error('title', 'content')
window.notify.info('title', 'content')
window.notify.warning('title', 'content')

options Parameters

ParameterDescriptionTypeDefault
nzDurationDuration in milliseconds. Set to 0 to prevent auto-dismiss.number4500
nzMaxStackMaximum number of notifications displayed at the same timenumber8
nzPauseOnHoverPause auto-dismiss when the mouse hovers over the notificationbooleantrue
nzAnimateEnable or disable animationbooleantrue
nzTopDistance from the top when notifications appear from the topstring24px
nzBottomDistance from the bottom when notifications appear from the bottomstring24px
nzPlacementPlacement: topLeft topRight bottomLeft bottomRight top bottomstringtopRight
nzDirectionText direction of the notification'ltr' | 'rtl'-

Rendering HTML in Components

Supported since 1.12.23+

By default, message, modal, and notification components only accept plain text. To render HTML, wrap the content with window.safeHtml to tell the framework the HTML is safe to render:

javascript
window.msg.error(window.safeHtml(`
    An error occurred
    <button style="margin-left:20px" onclick="window.location.hash = '/xxx'">View</button>
`), {
    nzDuration: 5000
})

Contributors

The avatar of contributor named as YuePeng YuePeng
The avatar of contributor named as Claude Opus 5 (1M context) Claude Opus 5 (1M context)

Changelog

Released under the Apache-2.0 License.