.An opinionated salute element for Vue. It is actually 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 tribute element for Vue. It is actually adjustable, but styled by nonpayment. Includes a wipe to reject animation.Installment.To start utilizing the library, mount it in your venture:.pnpm set up vue-sonner.or even.yarn include vue-sonner.Utilization.For Vue 3.
Provide a tribute.
For Nuxt 3.Determine a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).return deliver: toast. ).Usage Toaster oven component as well as $toast functionality anywhere in the Vue SFC.
Provide a toast.
Include the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Web link.EMS 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.Default.The majority of simple toast. You can customize it (as well as every other style) by passing an options things as the 2nd argument.salute(' Activity has been generated').Along with customized description:.salute(' Activity has actually been actually produced', explanation: 'Monday, January third at 6:00 pm'. ).Success.Provides a checkmark symbol before the message.toast.success(' Celebration has actually been made').Mistake.Leaves an inaccuracy icon before the notification.toast.error(' Occasion has actually not been actually produced').Activity.Presents a switch.tribute(' Activity has been created', activity: tag: 'Undo',.onClick: () => console.log(' Undo'). ).Assurance.Begins in a loading condition and will certainly update automatically after the promise resolves or even stops working.You can easily pass a functionality to the success/error information to combine the result/error of the guarantee.toast.promise(() => brand new Commitment(( resolve) => setTimeout( willpower, 2000)), loading: 'Loading',.results: (data: any kind of) => 'Excellence',.mistake: (records: any type of) => 'Mistake'. ).Customized Element.You can pass a Vue Part as the 1st debate rather than a cord to leave personalized Part while keeping nonpayment designing. You can make use of the brainless model below for a customized, unstyled tribute.Personalization.Brainless.You can utilize toast.custom to render an unstyled toast with customized jsx while keeping the capability.Concept.You can easily change the theme making use of the theme uphold. Nonpayment motif is actually lightweight.Posture.You may transform the position through the placement set on the element. Default is top-right.
Increased.Salutes can easily likewise be actually increased by default through the extend set. You may also alter the volume of noticeable salutes which is 3 through nonpayment.Designing for all toasts.You can easily style your salutes worldwide with the toastOptions uphold in the Toaster oven component.Styling for specific toast.tribute(' Event has actually been actually developed', type: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Include a near switch to all salutes that presents on hover by including the closeButton prop.Rich colors.You can easily make error and results state extra colorful through incorporating the richColors set.Custom-made offset.Balanced out from the sides of the display screen.Programmatically clear away salute.To take out a toast programmatically make use of toast.dismiss( id).const toastId = tribute(' Activity has actually been actually developed').toast.dismiss( toastId).You can easily also utilize the put away strategy without the id to put away all tributes.toast.dismiss().Programmatically eliminate tribute.You can easily change the timeframe of each salute by using the duration feature, or modify the period of all toasts such as this:.salute(' Celebration has actually been made', timeframe: 10000. ).// Persisent tribute.toast(' Event has actually been actually generated', period: Infinity. ).On Close Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss receives terminated when either the shut button receives clicked or the tribute is swiped. onAutoClose fires when the tribute goes away instantly after it is actually timeout (period prop).tribute(' Occasion has been actually developed', onDismiss: (t) => console.log( 'Toast along with i.d. $ t.id has been actually dismissed '),.onAutoClose: (t) =>console.log( 'Salute along with i.d. $ t.id has been actually finalized instantly '). ).Key-board concentration.You can easily concentrate on the salute area by pressing u2325/ alt + T. You can easily override it through giving a range of event.code worths for every trick.Creativity.sonner - An opinionated salute element for React.