Declarative Browser Notification as Web Components.
Using npm:
$ npm install x-notification
Import XNotification
and register it.
<script type="module">
import XNotification from 'https://unpkg.com/x-notification';
customElements.define('x-notification', XNotification);
</script>
Put <x-notification>
tag.
<x-notification autoshow title="Notification Title" delay="1000" timeout="3000" tag="tag">
Notification body
</x-notification>
If you set autoshow
attribute, a notification will be shown automatically.
To show it manually, execute show()
function.
document.querySelector('x-notification').show();
This is a required option . This will be set as notification title.
The direction of the notification. It can be auto , ltr , or rtl .
Specify the language used within the notification.
A string representing an extra content to display within the notification.
An ID for a given notification that allows to retrieve, replace or remove it if necessary.
The URL of an image to be used as an icon by the notification.
Delay for timing to show notification.
Timeout for timing to close notification automatically.
If you add this attribute, notification will be shown automatically.