Awesome Open Source
Awesome Open Source


semantic-release Greenkeeper badge nanocomponent 6

example gif

Have a look at the example page.


Install with npm install dom-notifications --save and use something like browserify to create a bundle for the browser.

var domNotifications = require('dom-notifications')
var notifications = domNotifications(options)


notifications.add({message: 'You are now logged in'}) // defaults to `info`
notifications.add({message: 'This is a warning', type: 'warning'})
notifications.error('Oh noes: File not found')

By default this uses octicons icon classes that are not included automatically. Here's a CDN link that serves octicons that you can include in your HTML:

<style rel="stylesheet" href="">

Have a look at the options to replace them with your own icon classes.


  repo: null, // Can be set to a GitHub url: ''
  icons: {
    error: 'octicon octicon-flame',
    warning: 'octicon octicon-alert',
    info: 'octicon octicon-info',
    success: 'octicon octicon-check',
    close: 'octicon octicon-x'


Setting the options.repo to a GitHub repository will add an Create an issue for this error button to the error notifications.

If you need more customization, instead of using the message property, you can also specify an element property and set it to DOMElement that will be the content.

For example with nanohtml:

  type: 'error',
  element: html`<div>
    <strong>My super custom <em>message</em>!</strong>

Notifications extends Nanocomponent.


Creates the root element for the component. Call this ones to append it to the DOM. Optionally state is an array of notifications


Add and show a notification. notification should be an object with a message property and optionally one of the types 'error', 'warning', 'info', 'success' (defaults to 'info').

If notification is a string it will use this as a message and default to 'info'.

Shortcut for .add({type: 'info', message: message})


Shortcut for .add({type: 'error', message: message})


Shortcut for .add({type: 'warning', message: message})


Shortcut for .add({type: 'success', message: message})

Use without styles

If you don't want the styles to be used (or applied automatically), you can also use the module like this:

var Notifications = require('dom-notifications/main')

var notifications = new Notifications()

// optionally apply styles yourself
var styles = require('dom-notifications/styles')
var insertCss = require('insert-css')


The styles for the notifications were adapted from ember-cli-notifications and atom.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Css (145,239
Dom (10,531
Atom (8,169
Octicons (155