vanilla-antd-message | Creating Toast Notification with Ant Design and Vanilla JavaScript

vanilla-antd-message is a vanilla JavaScript notification library based on Ant Design, it can allow us to create info, success, error, and warning toast notification easily.

vanilla-antd-message - Creating Toast Notification with Ant Design and Vanilla JavaScript

AuthorLinksMade withLast update
MinimalistYingOffice HomeJavaScriptSep 17, 2020

How to create notification using vanilla-antd-message?

1.Install vanilla-antd-message

# NPM
$ npm install vanilla-antd-message --save

2.Import vanilla-antd-message

import message from 'vanilla-antd-message'
import 'vanilla-antd-message/dist/style.css'

3.Create a new Message instance

const message = new Message();

3.Use Message instance to show differenet notifications

message.info('Info Message', duration, onClose);
message.success('Success Message', duration, onClose);
message.error('Error Message', duration, onClose);
message.warn('Warn Message', duration, onClose);

4.You can change the default duration in milliseconds

Message.prototype.duration = 3000

Leave a Reply

Your email address will not be published. Required fields are marked *