szboynono/mosha-vue-toastify
소개
A light weight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.
웹 및 앱 개발What you can do
- Super easy to setup! try follow this
- Support for Composition API
- Written in typescript, full typescript support
- Super light weight
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalMosha Vue Toastify
A lightweight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.
Vue Version Support: This library supports Vue 3.0+ and is tested with Vue 3.5.x. For the best experience, we recommend using Vue 3.5 or higher.
English | 简体中文

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
Requirements: Vue 3.0.0 or higher (Vue 3.5.x recommended)
With NPM:
$ npm install mosha-vue-toastify
With Yarn:
$ yarn add mosha-vue-toastify
Note: Make sure you have Vue 3 installed in your project. The library is backward compatible with Vue 3.0+ but takes advantage of newer features when using Vue 3.5+.
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 } } })- It can be just a string or a object like this:
Second argument: the second argument is an options object.
name type default description type 'info', 'danger', 'warning', 'success', 'default' 'default' Give the toast different styles and icons. timeout number 5000 How many ms you want the toggle to close itself? Note: passing -1 to the timeout will stop the modal from closing. position 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'top-center', 'bottom-center' 'top-right' Where do you want the toast to appear? showCloseButton boolean true Do you wanna show the close button ? showIcon boolean false Do you wanna show the icon ? transition 'bounce', 'zoom', 'slide' 'bounce' Which animation do you want? hideProgressBar boolean false Do we wanna hide the fancy progress bar? swipeClose boolean true Allows the user swipe close the toast toastBackgroundColor string default color Customize the background color of the toast. onClose function N/A This function will be called at the end of the toast's lifecycle Programatically closing The
createToastfunction returns an object that contains aclosefuntion that allows the user to programatically dismiss the toast. See below:import { createToast } from 'mosha-vue-toastify'; import CustomizedContent from "./CustomizedContent.vue"; import 'mosha-vue-toastify/dist/style.css'; export default defineComponent({ setup () { const toast = () => { // This close function can be used to close the toast const { close } = createToast(CustomizedContent) // close() } return { toast } } })To clear all the toasts, use the
clearToastsfunction. See belowimport { createToast, clearToasts } from 'mosha-vue-toastify'; import CustomizedContent from "./CustomizedContent.vue"; import 'mosha-vue-toastify/dist/style.css'; export default defineComponent({ setup () { const clear = () => { // clears all the toasts clearToasts() } return { clear } } })
Support
Give this project a ⭐ if you like it. Any suggestions are welcome!
관련 프로젝트 살펴보기
불러오는 중…