.An opinionated tribute component for Vue. It is actually a Vue slot of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated salute component for Vue. It's personalized, yet styled through nonpayment. Includes a swipe to reject animation.Setup.To begin using the library, mount it in your project:.pnpm put in vue-sonner.or.anecdote add vue-sonner.Utilization.For Vue 3.
Render a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster).profits deliver: toast. ).Use Toaster oven element and also $toast feature throughout the Vue SFC.
Leave a toast.
Incorporate the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Hyperlink.Ambulance version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD variation.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Styles.Nonpayment.Many general toast. You may individualize it (as well as every other style) through passing an alternatives things as the second disagreement.salute(' Occasion has actually been produced').With personalized explanation:.salute(' Event has actually been produced', explanation: 'Monday, January 3rd at 6:00 pm'. ).Success.Makes a checkmark symbol before the notification.toast.success(' Event has actually been actually made').Mistake.Provides an error icon before the notification.toast.error(' Activity has not been actually generated').Action.Presents a switch.salute(' Activity has actually been made', action: tag: 'Reverse',.onClick: () => console.log(' Undo'). ).Pledge.Starts in a filling state and also is going to improve instantly after the guarantee deals with or neglects.You can easily pass a feature to the success/error messages to integrate the result/error of the promise.toast.promise(() => brand-new Guarantee(( resolve) => setTimeout( resolve, 2000)), packing: 'Packing',.success: (data: any kind of) => 'Effectiveness',.mistake: (information: any kind of) => 'Inaccuracy'. ).Custom Element.You can pass a Vue Part as the very first debate as opposed to a strand to make customized Part while maintaining default designing. You can easily make use of the brainless variation listed below for a personalized, unstyled tribute.Modification.Headless.You can easily make use of toast.custom to provide an unstyled tribute along with personalized jsx while sustaining the functions.Theme.You can easily change the concept using the theme set. Default style is lightweight.Placement.You can easily modify the position by means of the position set on the element. Nonpayment is actually top-right.
Broadened.Salutes can easily also be actually broadened through default by means of the grow prop. You can also transform the amount of obvious salutes which is actually 3 by default.Designing for all salutes.You can easily type your tributes internationally with the toastOptions set in the Toaster component.Styling for individual toast.tribute(' Activity has actually been developed', design: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Add a close button to all toasts that shows on hover by incorporating the closeButton set.Rich shades.You can make inaccuracy as well as results state more multicolored through incorporating the richColors uphold.Customized balanced out.Made up for coming from the edges of the display screen.Programmatically eliminate salute.To take out a toast programmatically utilize toast.dismiss( i.d.).const toastId = tribute(' Celebration has actually been developed').toast.dismiss( toastId).You may also make use of the dismiss approach without the id to put away all salutes.toast.dismiss().Programmatically get rid of tribute.You may transform the duration of each toast by utilizing the duration attribute, or transform the duration of all tributes enjoy this:.tribute(' Celebration has been actually created', duration: 10000. ).// Persisent toast.tribute(' Occasion has actually been actually produced', timeframe: Infinity. ).On Shut Callback.You can easily pass onDismiss and also onAutoClose callbacks. onDismiss acquires axed when either the close button receives clicked on or the toast is actually wiped. onAutoClose fires when the toast fades away automatically after it's timeout (length prop).tribute(' Celebration has actually been actually developed', onDismiss: (t) => console.log( 'Tribute with id $ t.id has been actually rejected '),.onAutoClose: (t) =>console.log( 'Salute with id $ t.id has actually been shut automatically '). ).Key-board focus.You may focus on the salute area by pressing u2325/ alt + T. You may bypass it through offering a selection of event.code market values for every key.Creativity.sonner - An opinionated toast part for React.