.An opinionated tribute element for Vue. It's a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is actually an opinionated toast part for Vue. It's customizable, but styled through default. Comes with a wipe to dismiss computer animation.Setup.To start using the public library, mount it in your venture:.pnpm put up vue-sonner.or even.anecdote include vue-sonner.Utilization.For Vue 3.
Leave a tribute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back supply: toast. ).Make use of Toaster oven component as well as $tribute function throughout the Vue SFC.
Render a salute.
Include the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.EMS version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Nonpayment.Many standard toast. You can easily personalize it (as well as every other kind) through passing an alternatives things as the 2nd debate.salute(' Event has been developed').With custom description:.salute(' Celebration has been generated', summary: 'Monday, January third at 6:00 pm'. ).Excellence.Renders a checkmark icon in front of the notification.toast.success(' Activity has been actually developed').Mistake.Renders an error image before the message.toast.error(' Occasion has certainly not been produced').Activity.Presents a switch.salute(' Event has actually been made', action: tag: 'Reverse',.onClick: () => console.log(' Undo'). ).Promise.Begins in a packing condition as well as will certainly upgrade instantly after the commitment resolves or falls short.You can easily pass a function to the success/error information to incorporate the result/error of the guarantee.toast.promise(() => brand new Promise(( willpower) => setTimeout( willpower, 2000)), loading: 'Filling',.effectiveness: (information: any) => 'Excellence',.mistake: (information: any sort of) => 'Error'. ).Custom Element.You can pass a Vue Part as the first argument rather than a strand to leave personalized Part while preserving nonpayment styling. You may use the brainless version below for a personalized, unstyled salute.Modification.Brainless.You can utilize toast.custom to provide an unstyled salute with customized jsx while keeping the capability.Concept.You can easily transform the concept making use of the concept uphold. Nonpayment motif is actually light.Posture.You can easily alter the placement by means of the posture set on the part. Default is top-right.
Extended.Tributes can easily additionally be extended by default with the expand uphold. You can additionally transform the quantity of visible toasts which is actually 3 by nonpayment.Styling for all salutes.You can type your tributes globally along with the toastOptions set in the Toaster oven component.Styling for individual toast.tribute(' Celebration has been actually made', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a close switch to all toasts that reveals on hover through including the closeButton set.Rich shades.You can easily make inaccuracy and effectiveness state more colorful by adding the richColors set.Custom balanced out.Balanced out coming from the sides of the display.Programmatically take out toast.To eliminate a salute programmatically use toast.dismiss( i.d.).const toastId = tribute(' Occasion has actually been generated').toast.dismiss( toastId).You can easily likewise use the put away approach without the i.d. to dismiss all tributes.toast.dismiss().Programmatically take out salute.You may change the period of each tribute by using the duration attribute, or even alter the timeframe of all tributes like this:.tribute(' Event has been actually made', duration: 10000. ).// Persisent toast.tribute(' Activity has actually been actually generated', duration: Infinity. ).On Shut Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss obtains discharged when either the shut switch acquires hit or the tribute is wiped. onAutoClose fires when the toast fades away immediately after it is actually timeout (timeframe uphold).toast(' Occasion has actually been developed', onDismiss: (t) => console.log( 'Tribute with id $ t.id has actually been actually rejected '),.onAutoClose: (t) =>console.log( 'Toast with i.d. $ t.id has actually been finalized instantly '). ).Computer keyboard focus.You may focus on the salute field by pressing u2325/ alt + T. You can easily bypass it through supplying an assortment of event.code market values for each and every secret.Motivation.sonner - An opinionated salute element for React.