.An opinionated toast element for Vue. It is actually a Vue slot of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated salute part for Vue. It is actually customizable, but styled by default. Possesses a swipe to disregard animation.Setup.To start making use of the public library, mount it in your venture:.pnpm put up vue-sonner.or.anecdote include vue-sonner.Use.For Vue 3.
Make a tribute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster Oven).profits give: tribute. ).Usage Toaster component and $toast feature throughout the Vue SFC.
Leave a salute.
Incorporate the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Link.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Default.A lot of general salute. You can easily tailor it (as well as every other kind) through passing an options item as the second disagreement.toast(' Occasion has actually been actually developed').With customized explanation:.tribute(' Celebration has actually been actually generated', description: 'Monday, January 3rd at 6:00 pm'. ).Results.Leaves a checkmark image before the message.toast.success(' Activity has been produced').Inaccuracy.Leaves an inaccuracy image facing the notification.toast.error(' Occasion has not been created').Activity.Renders a switch.salute(' Activity has been made', activity: label: 'Reverse',.onClick: () => console.log(' Undo'). ).Pledge.Starts in a loading state as well as will improve instantly after the assurance settles or stops working.You may pass a feature to the success/error messages to integrate the result/error of the assurance.toast.promise(() => brand new Guarantee(( willpower) => setTimeout( willpower, 2000)), packing: 'Packing',.results: (information: any sort of) => 'Success',.mistake: (information: any) => 'Error'. ).Custom Part.You may pass a Vue Component as the first disagreement instead of a cord to leave personalized Component while maintaining default designing. You can easily utilize the brainless version listed below for a custom, unstyled salute.Customization.Brainless.You may utilize toast.custom to make an unstyled tribute along with customized jsx while keeping the performance.Concept.You can change the concept using the motif prop. Nonpayment motif is lightweight.Position.You can modify the position through the position uphold on the part. Nonpayment is actually top-right.
Broadened.Salutes can easily additionally be actually grown by default with the increase uphold. You can likewise modify the quantity of apparent salutes which is 3 through nonpayment.Styling for all toasts.You may style your tributes globally along with the toastOptions prop in the Toaster element.Designing for private salute.toast(' Occasion has been made', style: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Include a near switch to all salutes that presents on hover by adding the closeButton prop.Rich shades.You may help make error and also effectiveness condition extra vivid through adding the richColors prop.Customized countered.Balanced out from the sides of the display.Programmatically remove tribute.To get rid of a tribute programmatically utilize toast.dismiss( i.d.).const toastId = toast(' Celebration has been made').toast.dismiss( toastId).You can likewise utilize the put away method without the i.d. to dismiss all toasts.toast.dismiss().Programmatically clear away toast.You can easily alter the length of each toast by utilizing the duration characteristic, or transform the duration of all toasts such as this:.toast(' Celebration has been developed', duration: 10000. ).// Persisent tribute.salute(' Celebration has been made', duration: Immensity. ).On Close Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss obtains fired when either the shut switch receives clicked or the salute is swiped. onAutoClose fires when the salute goes away automatically after it's timeout (length prop).tribute(' Event has been developed', onDismiss: (t) => console.log( 'Toast along with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =>console.log( 'Tribute along with i.d. $ t.id has actually been actually finalized instantly '). ).Key-board focus.You can concentrate on the salute aspect through pressing u2325/ alt + T. You may bypass it by delivering an array of event.code values for each and every secret.Creativity.sonner - An opinionated tribute component for React.