.An opinionated salute part for Vue. It is actually a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated tribute part for Vue. It is actually customizable, however designated through default. Possesses a wipe to dismiss animation.Installation.To start making use of the public library, install it in your project:.pnpm install vue-sonner.or.yarn include vue-sonner.Usage.For Vue 3.
Leave a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster).profits offer: toast. ).Make use of Toaster element and $toast feature throughout the Vue SFC.
Provide a tribute.
Add the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Link.Ambulance model.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Styles.Default.The majority of essential tribute. You may tailor it (as well as some other style) by passing a choices item as the 2nd debate.salute(' Celebration has actually been made').With custom-made description:.salute(' Celebration has actually been made', description: 'Monday, January third at 6:00 pm'. ).Effectiveness.Provides a checkmark icon before the information.toast.success(' Activity has been created').Mistake.Provides a mistake image in front of the information.toast.error(' Celebration has not been actually generated').Action.Renders a button.tribute(' Activity has been actually created', action: tag: 'Undo',.onClick: () => console.log(' Undo'). ).Pledge.Starts in a filling condition as well as is going to improve instantly after the commitment settles or falls short.You may pass a functionality to the success/error notifications to integrate the result/error of the assurance.toast.promise(() => brand-new Commitment(( resolve) => setTimeout( willpower, 2000)), filling: 'Filling',.effectiveness: (information: any) => 'Success',.mistake: (information: any type of) => 'Inaccuracy'. ).Custom-made Part.You may pass a Vue Part as the first debate instead of a string to provide customized Component while keeping nonpayment designing. You can use the brainless model below for a personalized, unstyled salute.Customization.Brainless.You may utilize toast.custom to render an unstyled tribute with personalized jsx while keeping the functionality.Theme.You can transform the style utilizing the motif uphold. Default theme is lightweight.Posture.You can easily transform the posture by means of the placement uphold on the part. Default is top-right.
Extended.Toasts can also be actually grown through nonpayment via the grow prop. You may additionally modify the volume of obvious tributes which is 3 by nonpayment.Designing for all tributes.You can style your tributes around the globe along with the toastOptions set in the Toaster oven part.Designing for personal toast.salute(' Event has actually been generated', design: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Include a close switch to all toasts that reveals on hover through incorporating the closeButton set.Rich shades.You can make mistake as well as effectiveness condition more multicolored through adding the richColors set.Customized countered.Offset from the edges of the monitor.Programmatically clear away salute.To clear away a tribute programmatically utilize toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually made').toast.dismiss( toastId).You can additionally utilize the put away method without the id to dismiss all salutes.toast.dismiss().Programmatically take out toast.You may change the timeframe of each toast by utilizing the duration characteristic, or even transform the length of all salutes enjoy this:.tribute(' Occasion has actually been developed', timeframe: 10000. ).// Persisent toast.tribute(' Event has actually been actually created', duration: Immensity. ).On Close Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss gets axed when either the shut button gets clicked on or the toast is swiped. onAutoClose fires when the salute vanishes immediately after it is actually timeout (period prop).toast(' Celebration has actually been actually developed', onDismiss: (t) => console.log( 'Salute with id $ t.id has actually been actually dismissed '),.onAutoClose: (t) =>console.log( 'Toast along with i.d. $ t.id has actually been closed automatically '). ).Computer keyboard emphasis.You can concentrate on the tribute field by pushing u2325/ alt + T. You can easily override it by giving an array of event.code market values for each and every key.Motivation.sonner - An opinionated toast component for React.