.An opinionated tribute part for Vue. It is actually a Vue port of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated tribute part for Vue. It's adjustable, however designated by nonpayment. Comes with a swipe to dismiss computer animation.Installment.To start using the public library, mount it in your venture:.pnpm mount vue-sonner.or even.yarn add vue-sonner.Utilization.For Vue 3.
Leave a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster).profits provide: tribute. ).Usage Toaster component and $toast function anywhere in the Vue SFC.
Render a tribute.
Incorporate the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Web link.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Nonpayment.Most basic tribute. You may customize it (as well as some other style) through passing an alternatives object as the 2nd argument.toast(' Event has been actually made').With personalized description:.tribute(' Celebration has actually been made', explanation: 'Monday, January third at 6:00 pm'. ).Results.Leaves a checkmark symbol before the information.toast.success(' Activity has actually been actually generated').Error.Provides a mistake symbol facing the information.toast.error(' Activity has certainly not been developed').Activity.Presents a button.salute(' Activity has been created', activity: tag: 'Undo',.onClick: () => console.log(' Undo'). ).Guarantee.Starts in a loading condition as well as is going to update instantly after the guarantee deals with or fails.You can easily pass a feature to the success/error notifications to combine the result/error of the guarantee.toast.promise(() => brand new Commitment(( willpower) => setTimeout( resolve, 2000)), loading: 'Loading',.results: (records: any) => 'Results',.inaccuracy: (information: any) => 'Mistake'. ).Custom-made Part.You may pass a Vue Component as the 1st argument rather than a cord to make custom-made Part while keeping default styling. You can easily make use of the brainless model below for a customized, unstyled tribute.Modification.Headless.You may make use of toast.custom to leave an unstyled toast along with custom jsx while keeping the performance.Theme.You may alter the style making use of the style prop. Default style is actually lightweight.Setting.You can easily change the position via the setting uphold on the part. Nonpayment is actually top-right.
Expanded.Salutes can easily likewise be grown through nonpayment by means of the increase set. You can easily also alter the quantity of noticeable salutes which is 3 by default.Styling for all salutes.You can easily type your toasts internationally with the toastOptions set in the Toaster oven element.Designing for personal salute.toast(' Activity has been actually developed', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a close switch to all tributes that reveals on hover by incorporating the closeButton set.Rich colors.You can easily produce mistake and effectiveness state more vivid by adding the richColors set.Custom balanced out.Offset coming from the sides of the display.Programmatically remove salute.To clear away a toast programmatically utilize toast.dismiss( i.d.).const toastId = salute(' Event has actually been produced').toast.dismiss( toastId).You can likewise make use of the put away strategy without the id to dismiss all salutes.toast.dismiss().Programmatically take out toast.You can modify the duration of each toast by utilizing the timeframe attribute, or even change the timeframe of all tributes like this:.tribute(' Event has been made', length: 10000. ).// Persisent salute.tribute(' Celebration has actually been actually developed', duration: Infinity. ).On Close Callback.You may pass onDismiss and also onAutoClose callbacks. onDismiss acquires axed when either the near switch gets clicked on or the salute is actually swiped. onAutoClose fires when the toast goes away automatically after it's timeout (period prop).tribute(' Occasion has been developed', onDismiss: (t) => console.log( 'Salute with i.d. $ t.id has actually been disregarded '),.onAutoClose: (t) =>console.log( 'Toast along with id $ t.id has actually been closed immediately '). ).Key-board focus.You can easily focus on the salute area through pressing u2325/ alt + T. You can bypass it through supplying an array of event.code market values for each and every trick.Ideas.sonner - An opinionated toast component for React.