├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug_report.yml └── workflows │ └── release.yml ├── eslint.config.js ├── pnpm-workspace.yaml ├── .gitignore ├── tsconfig.node.json ├── src ├── vite-env.d.ts ├── Demo.vue ├── main.ts ├── Hero.vue ├── Expand.vue ├── Position.vue ├── App.vue ├── Types.vue ├── WithProgressBars.vue └── WithAvatars.vue ├── .changeset ├── config.json └── README.md ├── index.html ├── CHANGELOG.md ├── tsconfig.build.json ├── tsconfig.json ├── lib ├── VSonner.vue ├── types.ts ├── ProgressBar.vue ├── index.ts └── Toast.vue ├── api-extractor.json ├── LICENSE ├── vite.config.ts ├── public └── vite.svg ├── package.json └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: wobsoriano 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import antfu from '@antfu/eslint-config' 2 | 3 | export default antfu() 4 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | onlyBuiltDependencies: 2 | - '@parcel/watcher' 3 | - esbuild 4 | - unrs-resolver 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .DS_Store 3 | .idea 4 | *.log 5 | *.tgz 6 | coverage 7 | dist 8 | lib-cov 9 | logs 10 | node_modules 11 | temp 12 | .env 13 | .vscode 14 | -------------------------------------------------------------------------------- /tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node", 6 | "allowSyntheticDefaultImports": true 7 | }, 8 | "include": ["vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module '*.vue' { 4 | import type { DefineComponent } from 'vue' 5 | 6 | const component: DefineComponent, Record, unknown> 7 | export default component 8 | } 9 | -------------------------------------------------------------------------------- /src/Demo.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import '@mdi/font/css/materialdesignicons.css' 3 | import 'vuetify/styles' 4 | import { createVuetify } from 'vuetify' 5 | 6 | import App from './App.vue' 7 | 8 | const app = createApp(App) 9 | const vuetify = createVuetify() 10 | app.use(vuetify) 11 | 12 | app.mount('#app') 13 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vuetify Sonner 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Request a new feature 3 | labels: ['type: feature'] 4 | body: 5 | - type: textarea 6 | id: feature-description 7 | attributes: 8 | label: Describe the feature 9 | description: A clear and concise description of the feature. If you intend to submit a PR for this feature, tell us how in the description. Thanks! 10 | placeholder: Feature description 11 | validations: 12 | required: true 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # vuetify-sonner 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - d2dfb95: Fix incorrect styles export 8 | 9 | ## 0.4.1 10 | 11 | ### Patch Changes 12 | 13 | - 67e2931: Fix missing vue-sonner styles 14 | 15 | ## 0.4.0 16 | 17 | ### Minor Changes 18 | 19 | - 91d52f8: Bump vue-sonner to v2 20 | 21 | ## 0.3.21 22 | 23 | ### Patch Changes 24 | 25 | - 12e1853: Bump vue-sonner to 1.3.0 26 | 27 | ## 0.3.20 28 | 29 | ### Patch Changes 30 | 31 | - 6a5d845: Bump vue-sonner to 1.2.3 32 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "moduleResolution": "Node", 6 | "declaration": true, 7 | "declarationDir": "./temp", 8 | "emitDeclarationOnly": true, 9 | "noEmit": false, 10 | "outDir": "dist" 11 | }, 12 | "vueCompilerOptions": { 13 | "skipTemplateCodegen": true 14 | }, 15 | "include": [ 16 | "lib/**/*.ts", 17 | "lib/**/*.d.ts", 18 | "lib/**/*.tsx", 19 | "lib/**/*.vue" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "moduleResolution": "Node", 6 | "paths": { 7 | "@/*": ["lib/*"], 8 | "~/*": ["./src/*"] 9 | } 10 | }, 11 | "references": [{ "path": "./tsconfig.node.json" }], 12 | "include": [ 13 | "src/**/*.ts", 14 | "src/**/*.d.ts", 15 | "src/**/*.tsx", 16 | "src/**/*.vue", 17 | "lib/**/*.ts", 18 | "lib/**/*.d.ts", 19 | "lib/**/*.tsx", 20 | "lib/**/*.vue" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /lib/VSonner.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 28 | -------------------------------------------------------------------------------- /api-extractor.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 3 | "mainEntryPointFilePath": "/temp/index.d.ts", 4 | "bundledPackages": [], 5 | "compiler": { 6 | "tsconfigFilePath": "/tsconfig.build.json" 7 | }, 8 | "apiReport": { 9 | "enabled": false 10 | }, 11 | "docModel": { 12 | "enabled": false 13 | }, 14 | "dtsRollup": { 15 | "enabled": true, 16 | "untrimmedFilePath": "/dist/.d.ts" 17 | }, 18 | "tsdocMetadata": { 19 | "enabled": false 20 | }, 21 | "messages": { 22 | "extractorMessageReporting": { 23 | "ae-forgotten-export": { 24 | "logLevel": "none" 25 | }, 26 | "ae-missing-release-tag": { 27 | "logLevel": "none" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Hero.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 33 | 34 | 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Robert Soriano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/types.ts: -------------------------------------------------------------------------------- 1 | import type { ExternalToast, ToastClasses, ToastT, ToasterProps } from 'vue-sonner' 2 | import type { VAvatar, VBtn, VCard, VCardActions, VCardText, VIcon, VProgressLinear } from 'vuetify/components' 3 | import type { ComponentProps } from 'vue-component-type-helpers' 4 | 5 | export interface ToastProps { 6 | text: string 7 | description?: string 8 | vertical?: boolean 9 | cardProps?: ComponentProps 10 | cardTextProps?: ComponentProps 11 | cardActionsProps?: ComponentProps 12 | action?: { 13 | label?: string 14 | onClick?: () => void 15 | buttonProps?: ComponentProps 16 | } 17 | prependIcon?: string 18 | prependIconProps?: ComponentProps 19 | avatar?: string 20 | multipleAvatars?: string[] 21 | avatarProps?: ComponentProps 22 | progressBar?: boolean 23 | reverseProgressBar?: boolean 24 | progressDuration?: number 25 | progressBarProps?: ComponentProps 26 | loading?: boolean 27 | } 28 | 29 | export type Position = ToasterProps['position'] 30 | 31 | export type { 32 | ExternalToast, 33 | ToastT, 34 | ToastClasses, 35 | } 36 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | concurrency: ${{ github.workflow }}-${{ github.ref }} 9 | 10 | jobs: 11 | release: 12 | permissions: 13 | contents: write # to create release (changesets/action) 14 | pull-requests: write # to create pull request (changesets/action) 15 | name: Release 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout Repo 19 | uses: actions/checkout@v4 20 | with: 21 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits 22 | fetch-depth: 0 23 | - uses: pnpm/action-setup@v4 24 | with: 25 | version: 10.20.0 26 | 27 | - name: Setup Node.js 28 | uses: actions/setup-node@v4 29 | with: 30 | node-version: 20.x 31 | cache: pnpm 32 | 33 | - name: Install dependencies 34 | run: pnpm install --frozen-lockfile 35 | 36 | - name: Create Release Pull Request or Publish to npm 37 | id: changesets 38 | uses: changesets/action@v1 39 | with: 40 | publish: pnpm release 41 | env: 42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 44 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import type { UserConfig } from 'vite' 3 | import { defineConfig } from 'vite' 4 | import vue from '@vitejs/plugin-vue' 5 | import vuetify from 'vite-plugin-vuetify' 6 | 7 | // https://vitejs.dev/config/ 8 | export default defineConfig(({ mode }) => { 9 | const userConfig: UserConfig = {} 10 | 11 | if (mode === 'lib') { 12 | userConfig.build = { 13 | lib: { 14 | entry: path.resolve(__dirname, 'lib/index.ts'), 15 | name: 'VuetifySonner', 16 | fileName: 'vuetify-sonner', 17 | }, 18 | outDir: 'dist', 19 | emptyOutDir: true, 20 | cssCodeSplit: false, 21 | sourcemap: true, 22 | rollupOptions: { 23 | external: ['vue', 'vuetify', /vuetify\/.+/, 'vue-sonner'], 24 | output: [ 25 | { 26 | format: 'cjs', 27 | entryFileNames: `vuetify-sonner.cjs`, 28 | }, 29 | { 30 | format: 'es', 31 | entryFileNames: `vuetify-sonner.js`, 32 | preserveModules: false, 33 | }, 34 | ], 35 | }, 36 | } 37 | } 38 | 39 | return { 40 | plugins: [ 41 | vue(), 42 | vuetify({ 43 | autoImport: true, 44 | }), 45 | ], 46 | resolve: { 47 | alias: { 48 | '@/': `${path.resolve(__dirname, 'lib')}/`, 49 | }, 50 | }, 51 | ...userConfig, 52 | } 53 | }) 54 | -------------------------------------------------------------------------------- /public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Expand.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 47 | 48 | 68 | -------------------------------------------------------------------------------- /lib/ProgressBar.vue: -------------------------------------------------------------------------------- 1 | 55 | 56 | 59 | -------------------------------------------------------------------------------- /lib/index.ts: -------------------------------------------------------------------------------- 1 | import { h, markRaw } from 'vue' 2 | import { toast as toastOriginal } from 'vue-sonner' 3 | import type { ExternalToast, ToastProps } from './types' 4 | import VSonner from './VSonner.vue' 5 | import Toast from './Toast.vue' 6 | 7 | type Options = Omit & Pick 8 | 9 | function toastFunction(text: string, options?: Options) { 10 | const { description, action, ...rest } = options || {} 11 | return toastOriginal.custom(markRaw(h(Toast, { 12 | ...rest, 13 | progressBar: options?.progressBar ?? false, 14 | progressDuration: options?.duration ?? 5000, 15 | progressBarProps: { 16 | ...options?.progressBarProps, 17 | indeterminate: options?.loading, 18 | }, 19 | description, 20 | action, 21 | text, 22 | })), { 23 | ...rest, 24 | unstyled: true, 25 | }) 26 | } 27 | 28 | function createToastFunction(color: string, icon: string) { 29 | return function (text: string, options?: Options) { 30 | return toastFunction(text, { 31 | prependIcon: icon, 32 | cardProps: { 33 | color, 34 | ...options?.cardProps, 35 | }, 36 | ...options, 37 | }) 38 | } 39 | } 40 | 41 | export const toast = Object.assign(toastFunction, { 42 | success: createToastFunction('success', 'mdi-check-circle'), 43 | error: createToastFunction('error', 'mdi-cancel'), 44 | warning: createToastFunction('warning', 'mdi-alert'), 45 | info: createToastFunction('info', 'mdi-alert-circle'), 46 | primary: createToastFunction('primary', 'mdi-bell'), 47 | secondary: createToastFunction('secondary', 'mdi-bell'), 48 | dismiss(toastId?: number | string) { 49 | return toastOriginal.dismiss(toastId) 50 | }, 51 | toastOriginal, 52 | }) 53 | 54 | export { 55 | VSonner, 56 | } 57 | -------------------------------------------------------------------------------- /src/Position.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 51 | 52 | 72 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Report an issue with vuetify-sonner 3 | labels: ['type: bug'] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to fill out this bug report! 9 | - type: textarea 10 | id: bug-description 11 | attributes: 12 | label: Describe the bug 13 | description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us how in the description. Thanks! 14 | placeholder: Bug description 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: reproduction 19 | attributes: 20 | label: Reproduction 21 | description: | 22 | Provide a minimal reproduction of the problem. Include a StackBlitz or link to a GitHub repository that we can easily run to recreate the issue. If a report is vague and does not have a reproduction, it will be closed without warning. 23 | 24 | To get started, you can use the following StackBlitz template: 25 | https://stackblitz.com/edit/vitejs-vite-sbuuep 26 | validations: 27 | required: true 28 | - type: textarea 29 | id: logs 30 | attributes: 31 | label: Logs 32 | description: Please include browser console and server logs around the time this bug occurred. Optional if provided reproduction. Please try not to insert an image but copy paste the log text. 33 | render: bash 34 | - type: textarea 35 | id: system-info 36 | attributes: 37 | label: System Info 38 | description: Output of `npx envinfo --system --npmPackages vue,vuetify --binaries --browsers` 39 | render: bash 40 | placeholder: System, Binaries, Browsers 41 | validations: 42 | required: true 43 | - type: dropdown 44 | id: severity 45 | attributes: 46 | label: Severity 47 | description: Select the severity of this issue 48 | options: 49 | - annoyance 50 | - blocking an upgrade 51 | - blocking all usage of vuetify-sonner 52 | validations: 53 | required: true 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuetify-sonner", 3 | "type": "module", 4 | "version": "0.4.2", 5 | "packageManager": "pnpm@10.20.0", 6 | "description": "Stackable toast component for Vuetify.", 7 | "author": "Robert Soriano ", 8 | "license": "MIT", 9 | "homepage": "https://github.com/wobsoriano/vuetify-sonner#readme", 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/wobsoriano/vuetify-sonner.git" 13 | }, 14 | "bugs": "https://github.com/wobsoriano/vuetify-sonner/issues", 15 | "keywords": [ 16 | "vuetify", 17 | "vue", 18 | "confirm", 19 | "snackbar", 20 | "toast" 21 | ], 22 | "sideEffects": false, 23 | "exports": { 24 | ".": { 25 | "types": "./dist/vuetify-sonner.d.ts", 26 | "import": "./dist/vuetify-sonner.js", 27 | "require": "./dist/vuetify-sonner.cjs" 28 | }, 29 | "./style.css": { 30 | "import": "./dist/vuetify-sonner.css", 31 | "require": "./dist/vuetify-sonner.css" 32 | } 33 | }, 34 | "main": "./dist/vuetify-sonner.cjs", 35 | "module": "./dist/vuetify-sonner.js", 36 | "types": "./dist/vuetify-sonner.d.ts", 37 | "files": [ 38 | "dist" 39 | ], 40 | "scripts": { 41 | "build": "vite build --mode lib && rimraf dist/vite.svg && pnpm build:types", 42 | "build:types": "vue-tsc -p tsconfig.build.json && api-extractor run", 43 | "dev": "vite", 44 | "dev:build": "vite build", 45 | "dev:preview": "vite preview", 46 | "lint": "eslint .", 47 | "prepublishOnly": "pnpm build", 48 | "release": "changeset publish" 49 | }, 50 | "peerDependencies": { 51 | "vue": "^3.3.0", 52 | "vuetify": "^3.3.0" 53 | }, 54 | "dependencies": { 55 | "vue-component-type-helpers": "^3.1.3", 56 | "vue-sonner": "^2.0.9" 57 | }, 58 | "devDependencies": { 59 | "@antfu/eslint-config": "^2.27.3", 60 | "@changesets/cli": "^2.29.7", 61 | "@mdi/font": "^7.4.47", 62 | "@microsoft/api-extractor": "^7.54.0", 63 | "@types/node": "^20.19.24", 64 | "@vitejs/plugin-vue": "^6.0.1", 65 | "@vue/tsconfig": "^0.8.1", 66 | "bumpp": "^10.3.1", 67 | "eslint": "^9.39.1", 68 | "rimraf": "^5.0.10", 69 | "roboto-fontface": "^0.10.0", 70 | "sass": "^1.93.3", 71 | "typescript": "^5.8.2", 72 | "vite": "^7.2.0", 73 | "vite-plugin-vuetify": "^2.1.2", 74 | "vue": "^3.5.24", 75 | "vue-tsc": "^3.1.3", 76 | "vuetify": "^3.10.9" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 69 | 70 | 94 | -------------------------------------------------------------------------------- /src/Types.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 63 | 64 | 84 | -------------------------------------------------------------------------------- /src/WithProgressBars.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 86 | 87 | 98 | -------------------------------------------------------------------------------- /src/WithAvatars.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 74 | 75 | 86 | -------------------------------------------------------------------------------- /lib/Toast.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 81 | 82 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | https://github.com/wobsoriano/vuetify-sonner/assets/13049130/3dc381ec-95b2-4bd1-9df6-624210e9d9f4 2 | 3 | # vuetify-sonner 4 | 5 | Stackable toast component for Vuetify. 6 | 7 | > [!WARNING] 8 | > Snackbars should appear one at a time. This component breaks the Material [spec](https://m2.material.io/components/snackbars#behavior). 9 | 10 | ## Installation 11 | 12 | ```bash 13 | npm install vuetify-sonner 14 | ``` 15 | 16 | ## Usage 17 | 18 | Add `` to your app, it will be the place where all your toasts will be rendered. After that you can use `toast()` from anywhere in your app. 19 | 20 | ```vue 21 | 25 | 26 | 34 | ``` 35 | ### Default 36 | 37 | Most basic toast. You can customize it by passing an options object as the second argument. 38 | 39 | ```js 40 | toast('My first toast') 41 | ``` 42 | 43 | With description: 44 | 45 | ```js 46 | toast('Event has been created', { 47 | description: 'Monday, January 3rd at 6:00pm', 48 | }) 49 | ``` 50 | 51 | ### Action 52 | 53 | Renders a button. 54 | 55 | ```js 56 | toast('Event has been created', { 57 | action: { 58 | label: 'Undo', 59 | onClick: () => console.log('Undo'), 60 | buttonProps: { 61 | // v-btn props 62 | } 63 | }, 64 | }) 65 | ``` 66 | 67 | ## Customization 68 | 69 | Behind the scenes, the toast component uses Vuetify [Cards](https://vuetifyjs.com/en/components/cards/), as the snackbar component has its own overlay logic. 70 | 71 | ### Position 72 | 73 | You can change the position through the `position` prop on the `` component. Default is `bottom-center`. 74 | 75 | ```vue 76 | 77 | ``` 78 | 79 | ### Expanded 80 | 81 | Toasts can also be expanded by default through the `expand` prop. You can also change the amount of visible toasts which is 3 by default. 82 | 83 | ```vue 84 | 85 | ``` 86 | 87 | ### Toast Options 88 | 89 | ```js 90 | toast('Event has been created', { 91 | description: 'Some more context of the notification', // subtitle of the snackbar 92 | cardProps: { 93 | color: 'success', 94 | class: 'my-toast', 95 | // v-card props 96 | }, 97 | cardTextProps: { 98 | // v-card-text props 99 | }, 100 | cardActionsProps: { 101 | // v-card-actions props 102 | }, 103 | prependIcon: 'mdi-check-circle', 104 | prependIconProps: { 105 | // v-icon props 106 | }, 107 | progressBar: boolean, // show or hide countdown progress bar 108 | progressBarProps: { 109 | // v-progress-linear props 110 | }, 111 | reverseProgressBar: boolean, // changes progress bar direction 112 | loading: boolean, // makes progressbar indeterminate 113 | avatar: 'https://url.to/my/image.jpg', // avatar image url, 114 | multipleAvatars: [ 115 | 'https://url.to/image/1.jpg', 116 | 'https://url.to/image/2.jpg', 117 | 'https://url.to/image/3.jpg' 118 | // will display first 5 images 119 | ], 120 | avatarProps: { 121 | // v-avatar props 122 | } 123 | }) 124 | ``` 125 | 126 | ### Programmatically remove toast 127 | 128 | To remove a toast programmatically use `toast.dismiss(id)`. 129 | 130 | ```js 131 | const toastId = toast('Event has been created') 132 | 133 | toast.dismiss(toastId) 134 | ``` 135 | 136 | You can also use the dismiss method without the id to dismiss all toasts. 137 | 138 | ```js 139 | // Removes all toasts 140 | 141 | toast.dismiss() 142 | ``` 143 | 144 | ### Duration 145 | 146 | You can change the duration of each toast by using the `duration` property, or change the duration of all toasts like this: 147 | 148 | ```vue 149 | 150 | ``` 151 | 152 | ```js 153 | toast('Event has been created', { 154 | duration: 10000, 155 | }) 156 | 157 | // Persisent toast 158 | toast('Event has been created', { 159 | duration: Number.POSITIVE_INFINITY, 160 | }) 161 | ``` 162 | 163 | ### On Close Callback 164 | 165 | You can pass `onDismiss` and `onAutoClose` callbacks. `onDismiss` gets fired when either the close button gets clicked or the toast is swiped. `onAutoClose` fires when the toast disappears automatically after it's timeout (`duration` prop). 166 | 167 | ```js 168 | toast('Event has been created', { 169 | onDismiss: t => console.log(`Toast with id ${t.id} has been dismissed`), 170 | onAutoClose: t => console.log(`Toast with id ${t.id} has been closed automatically`), 171 | }) 172 | ``` 173 | 174 | ### Keyboard focus 175 | 176 | You can focus on the toast area by pressing ⌥/alt + T. You can override it by providing an array of event.code values for each key. 177 | 178 | ```vue 179 | 180 | ``` 181 | 182 | ### Use Underlying `Vue-Sonner` 183 | 184 | `vuetify-sonner`, as a wrapper over the `vue-sonner` library, grants access to all the underlying methods and properties of `vue-sonner` by using the `toast.toastOriginal` property, e.g. 185 | 186 | ```js 187 | // Using Vue-Sonners Promise toast 188 | import { toast } from 'vuetify-sonner' 189 | 190 | const promise = () => new Promise(resolve => setTimeout(resolve, 2000)) 191 | 192 | toast.toastOriginal 193 | .promise(promise, { 194 | loading: 'Loading...', 195 | success: (data) => { 196 | return `${data} toast has been added` 197 | }, 198 | error: (data: any) => 'Error', 199 | }) 200 | ``` 201 | 202 | See [here for more on using vue-sonner](https://vue-sonner.vercel.app/) 203 | 204 | ## Nuxt Usage 205 | 206 | ```ts 207 | export default defineNuxtConfig({ 208 | build: { 209 | transpile: ['vue-sonner'] 210 | } 211 | }) 212 | ``` 213 | 214 | ```vue 215 | 219 | 220 | 230 | ``` 231 | 232 | ## License 233 | 234 | MIT 235 | --------------------------------------------------------------------------------