Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuejs-notification

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuejs-notification

Simple notify component for VueJS 2

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Notify

Build Status Coverage Status

A simple bootstrap|bulma styled Vue component for notifications. Compatible with Vue 2.x

Requirements

Required packages:

  • vue 2+
  • velocity-animate 1.5+

Optional packages:

  • bootstrap or bulma (only used for styling)

Install

$ yarn add vuejs-notification

Then in your main.js:

import Notify from 'vue2-notify'

// Use Notify
Vue.use(Notify)

Usage

Inside your component:

this.$notify('A message that should be displayed', 'type')

or

Vue.$notify('A message that should be displayed', 'type')

You may use short type call:

this.$notify.success('This is success message');

or

Vue.$notify('This is success message');

Bulma users can call this.$notify.danger('Error message');, this.$notify.danger() is link to this.$notify.error()

Configuration

OptionTypeDefaultDescription
itemClassString'alert col-12'The class that the notification is wrapped in, defaults to the default bootstrap style
durationInteger500The amount of milliseconds that the animation should take (slideDown/slideUp, fadeIn/fadeOut)
visibilityInteger2000The amount of milliseconds that the notification should be visible (if notification is not permanent)
positionString'top-left'The location of the notification, currently possible: top-left, top-right, top-full, bottom-left, bottom-right and bottom-full
enterString'slideDown'Entry animation type, currently possible: slideDown, fadeIn
leaveString'slideUp'Exit animation type, currently possible: slideUp, fadeOut
permanentBooleanfalseDisable notification auto close
modeString'text'Set 'html' to output real html. Only use HTML interpolation on trusted content and never on user-provided content.
closeButtonClassBoolean / StringfalseClass name for close button. If false - close button will not be displayed. ( Example: set 'delete' for bulma or 'close' for bootstrap.)

Configuration options can be provided as options in the Vue.use statement:

// Use Notify
Vue.use(Notify, {visibility: 5000, permanent: true})

Overriding configuration

You can override the itemClass, iconClass, visibility, mode or closeButtonClass options on a per usage basis:

this.$notify('A message that should be displayed', 'type', { itemClass: 'alert col-6 alert-info', iconClass: 'fa fa-lg fa-handshake-o', visibility: 10000 })

Type should be one of the types defined in the configuration of the component.

Types

Defines the type of notifications that can be triggered

TypeItemClassIconClass
info'alert-info''fa fa-lg fa-info-circle'
error'alert-danger''fa fa-lg fa-exclamation-triangle'
warning'alert-warning''fa fa-lg fa-exclamation-circle'
success'alert-success''fa fa-lg fa-check-circle'

You can override the default list of types in the following way, for example to use glyphicons instead of font awesome icons:

const types = {
  info: { itemClass: 'alert-info', iconClass: 'glyphicons glyphicons-info-sign'},
  ..
  success: { itemClass: 'alert-success', iconClass: 'glyphicons glyphicons-ok'},
}

Vue.$notify.setTypes(types)

Examples

Using vue2-notify with Bulma

In app.js:

import Notify from 'vue2-notify'
Vue.use(Notify, {
  itemClass: 'notification'
})
const types = {
  info: { itemClass: 'is-info', },
  error: { itemClass: 'is-danger' },
  warning: { itemClass: 'is-warning' },
  success: { itemClass: 'is-success', iconClass: 'fa fa-lg fa-check-circle' }
}

Vue.$notify.setTypes(types);

And call this.$notify method as usual:

this.$notify('A message that should be displayed', 'info')

or

this.$notify.info('A message that should be displayed')

HTML in notification

this.$notify('<p>My HTML <br/>message</p>', 'info', {mode: 'html'})

or

this.$notify.error('<p>My HTML <br/>message</p>', {mode: 'html'})

Permanent notification

this.$notify('Permanent message', 'info', {permanent: true})

Keywords

FAQs

Package last updated on 05 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc