.An opinionated toast part for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is actually an opinionated salute component for Vue. It is actually personalized, however styled through default. Possesses a swipe to dismiss animation.Installment.To begin utilizing the public library, install it in your task:.pnpm mount vue-sonner.or.yarn add vue-sonner.Use.For Vue 3.
Provide a tribute.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, toast from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster Oven).profits deliver: toast. ).Use Toaster element and $salute feature throughout the Vue SFC.
Make a salute.
Include the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.EMS model.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Styles.Nonpayment.A lot of basic salute. You can easily customize it (and some other type) through passing an alternatives object as the 2nd debate.toast(' Event has been created').Along with personalized description:.salute(' Celebration has been produced', explanation: 'Monday, January third at 6:00 pm'. ).Effectiveness.Makes a checkmark image in front of the message.toast.success(' Activity has been actually made').Inaccuracy.Makes an inaccuracy symbol in front of the information.toast.error(' Event has actually certainly not been actually produced').Action.Presents a switch.tribute(' Celebration has actually been generated', action: tag: 'Undo',.onClick: () => console.log(' Undo'). ).Assurance.Starts in a filling state and will definitely improve automatically after the commitment deals with or even stops working.You can pass a function to the success/error notifications to combine the result/error of the commitment.toast.promise(() => new Pledge(( willpower) => setTimeout( fix, 2000)), packing: 'Loading',.success: (information: any) => 'Effectiveness',.error: (data: any sort of) => 'Error'. ).Custom-made Part.You can pass a Vue Element as the very first disagreement rather than a strand to render custom-made Element while keeping nonpayment designing. You can use the headless model below for a custom, unstyled salute.Customization.Brainless.You can use toast.custom to leave an unstyled salute with personalized jsx while keeping the performance.Motif.You may transform the theme utilizing the concept set. Nonpayment theme is light.Posture.You can easily modify the placement through the position prop on the element. Default is actually top-right.
Increased.Salutes can easily additionally be actually extended by default via the grow set. You can easily additionally transform the quantity of obvious salutes which is 3 by default.Designing for all tributes.You may type your toasts globally along with the toastOptions prop in the Toaster oven component.Designing for personal tribute.salute(' Celebration has actually been actually generated', design: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Add a near button to all salutes that shows on hover through incorporating the closeButton prop.Rich different colors.You can help make inaccuracy and excellence state a lot more vibrant through incorporating the richColors set.Customized countered.Offset from the edges of the display.Programmatically eliminate tribute.To get rid of a salute programmatically utilize toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually developed').toast.dismiss( toastId).You can easily likewise use the dismiss procedure without the id to put away all tributes.toast.dismiss().Programmatically eliminate salute.You can change the length of each toast by utilizing the length home, or even change the period of all tributes enjoy this:.salute(' Event has actually been made', period: 10000. ).// Persisent salute.toast(' Occasion has actually been generated', timeframe: Infinity. ).On Close Callback.You may pass onDismiss as well as onAutoClose callbacks. onDismiss gets terminated when either the close switch acquires hit or the toast is swiped. onAutoClose fires when the tribute vanishes immediately after it's timeout (duration prop).toast(' Activity has actually been created', onDismiss: (t) => console.log( 'Toast along with i.d. $ t.id has actually been rejected '),.onAutoClose: (t) =>console.log( 'Tribute with id $ t.id has actually been actually finalized instantly '). ).Key-board focus.You may focus on the salute field by pushing u2325/ alt + T. You can easily bypass it through offering an array of event.code values for each key.Motivation.sonner - An opinionated toast component for React.