.An opinionated tribute 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 salute part for Vue. It's personalized, yet styled by default. Possesses a wipe to reject animation.Setup.To start using the public library, install it in your task:.pnpm mount vue-sonner.or.anecdote add vue-sonner.Use.For Vue 3.
Make a toast.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).return deliver: toast. ).Make use of Toaster oven component and $salute functionality anywhere in the Vue SFC.
Provide a salute.
Include the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.EMS 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 general tribute. You may tailor it (and also every other type) through passing a possibilities item as the 2nd debate.toast(' Celebration has been actually made').Along with custom-made summary:.salute(' Occasion has been actually developed', explanation: 'Monday, January third at 6:00 pm'. ).Results.Leaves a checkmark image before the information.toast.success(' Event has been developed').Inaccuracy.Renders a mistake image in front of the information.toast.error(' Activity has actually not been produced').Activity.Presents a button.tribute(' Occasion has actually been actually produced', action: label: 'Reverse',.onClick: () => console.log(' Undo'). ).Promise.Starts in a packing state and also is going to improve immediately after the pledge addresses or falls short.You can easily pass a feature to the success/error information to integrate the result/error of the promise.toast.promise(() => brand-new Pledge(( willpower) => setTimeout( willpower, 2000)), loading: 'Packing',.results: (information: any type of) => 'Effectiveness',.error: (records: any) => 'Mistake'. ).Custom-made Component.You can pass a Vue Part as the 1st argument rather than a strand to make custom-made Component while maintaining default designing. You may utilize the headless version below for a customized, unstyled salute.Personalization.Headless.You may utilize toast.custom to leave an unstyled toast with custom jsx while sustaining the performance.Motif.You can change the motif utilizing the theme prop. Nonpayment concept is light.Placement.You can easily modify the placement through the placement prop on the part. Default is top-right.
Broadened.Salutes can easily additionally be extended by nonpayment via the extend prop. You can also alter the volume of apparent toasts which is 3 through nonpayment.Styling for all tributes.You may type your salutes internationally along with the toastOptions uphold in the Toaster element.Designing for individual salute.tribute(' Event has been developed', type: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Add a near button to all toasts that shows on hover by adding the closeButton prop.Rich colours.You can easily make inaccuracy and effectiveness state more vivid through adding the richColors prop.Personalized made up for.Made up for from the edges of the screen.Programmatically get rid of toast.To get rid of a toast programmatically utilize toast.dismiss( i.d.).const toastId = salute(' Activity has been actually generated').toast.dismiss( toastId).You can likewise make use of the dismiss strategy without the i.d. to dismiss all toasts.toast.dismiss().Programmatically take out tribute.You can transform the duration of each tribute by using the timeframe quality, or even modify the length of all salutes enjoy this:.salute(' Activity has actually been actually produced', timeframe: 10000. ).// Persisent toast.toast(' Event has actually been made', period: Immensity. ).On Shut Callback.You may pass onDismiss and also onAutoClose callbacks. onDismiss receives fired when either the near button gets hit or the toast is actually swiped. onAutoClose fires when the tribute fades away immediately after it's timeout (timeframe prop).tribute(' Activity has actually been generated', onDismiss: (t) => console.log( 'Toast along with i.d. $ t.id has been disregarded '),.onAutoClose: (t) =>console.log( 'Toast with i.d. $ t.id has been actually finalized immediately '). ).Key-board emphasis.You can concentrate on the tribute area by pressing u2325/ alt + T. You can bypass it by supplying a selection of event.code worths for each key.Ideas.sonner - An opinionated toast element for React.