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

mosha-vue-toastify

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mosha-vue-toastify

A light weight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.

  • 1.0.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3K
decreased by-31.09%
Maintainers
1
Weekly downloads
 
Created
Source

Mosha Vue Toastify

Build Status

A lightweight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.

English | 简体中文

alt text

Talk is cheap, show me the demo

Try it out in the playground in the documentation

Features

  • Super easy to setup! try follow this
  • Swipe to close
  • Support for Composition API
  • Written in typescript, full typescript support
  • Super light weight
  • Define behavior per toast
  • Fun progress bar to display remaining time
  • A lot more coming!

Installation

With NPM:

$ npm install mosha-vue-toastify

With Yarn:

$ yarn add mosha-vue-toastify

The gist

<template>
  <button @click="toast">Toast it!</button>
</template>
<script lang='ts'>
import { defineComponent } from 'vue'
// import the library
import { createToast } from 'mosha-vue-toastify';
// import the styling for the toast
import 'mosha-vue-toastify/dist/style.css'

export default defineComponent({
  name: 'HelloWorld',
  setup () {
    const toast = () => {
        createToast('Wow, easy')
    }
    return { toast }
  }
})
</script>

Configuration

The createToast function accepts 2 arguments:

  • First argument:

    • It can be just a string or a object like this: { title: 'some title', description: 'some good description'}. By the way, description now accepts html, for more customization, we recommand trying out the custom component approach
    • It can also accept a Vue 3 component or a VNode if you need more customization, e.g.
      // without props
      import { createToast } from 'mosha-vue-toastify';
      import CustomizedContent from "./CustomizedContent.vue";
      import 'mosha-vue-toastify/dist/style.css';
    
      export default defineComponent({
        setup () {
          const toast = () => {
              createToast(CustomizedContent)
          }
          return { toast }
        }
      })
    
      // with props
      import { createToast, withProps } from 'mosha-vue-toastify';
      import CustomizedContent from "./CustomizedContent.vue";
      import 'mosha-vue-toastify/dist/style.css';
    
      export default defineComponent({
        setup () {
          const toast = () => {
              createToast(withProps(CustomizedContent, { yourFavProp: 'bruh' }))
          }
          return { toast }
        }
      })
    
  • Second argument: the second argument is an options object.

Options:

nametypedefaultdescription
type'info', 'danger', 'warning', 'success', 'default''default'Give the toast different styles and icons.
timeoutnumber5000How many ms you want the toggle to close itself?
position'top-left', 'top-right', 'bottom-left', 'bottom-right', 'top-center', 'bottom-center''top-right'Where do you want the toast to appear?
showCloseButtonbooleantrueDo you wanna show the close button ?
showIconbooleanfalseDo you wanna show the icon ?
transition'bounce', 'zoom', 'slide''bounce'Which animation do you want?
hideProgressBarbooleanfalseDo we wanna hide the fancy progress bar?
swipeClosebooleantrueAllows the user swipe close the toast
toastBackgroundColorstringdefault colorCustomize the background color of the toast.
onClosefunctionN/AThis function will be called at the end of the toast's lifecycle

Support

Give this project a ⭐ if you like it. Any suggestions are welcome!

Keywords

FAQs

Package last updated on 05 Aug 2021

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