Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute component for Vue. It's a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated toast component for Vue. It is actually personalized, but styled through default. Comes with a wipe to dismiss computer animation.Installment.To start utilizing the library, mount it in your job:.pnpm mount vue-sonner.or even.anecdote include vue-sonner.Utilization.For Vue 3.
Provide a toast.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, toast from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).come back offer: tribute. ).Make use of Toaster element and also $toast function throughout the Vue SFC.
Render a salute.
Include the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.EMS variation.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.Most basic tribute. You may tailor it (as well as some other style) by passing an alternatives item as the 2nd disagreement.tribute(' Occasion has been actually created').With personalized description:.salute(' Celebration has been generated', summary: 'Monday, January 3rd at 6:00 pm'. ).Success.Renders a checkmark symbol facing the information.toast.success(' Occasion has been actually created').Error.Leaves a mistake icon before the notification.toast.error(' Activity has actually certainly not been produced').Action.Presents a button.tribute(' Event has actually been actually created', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Assurance.Begins in a loading state and also is going to update instantly after the assurance deals with or neglects.You can pass a functionality to the success/error messages to integrate the result/error of the assurance.toast.promise(() =&gt brand new Assurance(( fix) =&gt setTimeout( resolve, 2000)), loading: 'Filling',.results: (data: any kind of) =&gt 'Excellence',.inaccuracy: (records: any) =&gt 'Inaccuracy'. ).Customized Component.You can easily pass a Vue Component as the initial debate as opposed to a string to provide customized Element while preserving nonpayment styling. You may make use of the brainless variation listed below for a custom, unstyled tribute.Modification.Headless.You can use toast.custom to make an unstyled toast with personalized jsx while preserving the performance.Motif.You can alter the concept using the motif set. Default style is actually light.Posture.You can change the setting through the position prop on the element. Default is actually top-right.
Grown.Tributes can easily also be actually extended through default with the broaden prop. You can additionally transform the amount of visible salutes which is 3 through default.Designing for all toasts.You can style your tributes around the world along with the toastOptions uphold in the Toaster part.Designing for individual tribute.toast(' Celebration has actually been actually developed', design: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Add a close switch to all toasts that reveals on hover through incorporating the closeButton set.Rich different colors.You can help make inaccuracy and effectiveness condition even more vivid through including the richColors uphold.Customized balanced out.Countered from the edges of the display.Programmatically clear away toast.To take out a salute programmatically utilize toast.dismiss( id).const toastId = tribute(' Occasion has actually been actually generated').toast.dismiss( toastId).You can also utilize the put away method without the i.d. to put away all salutes.toast.dismiss().Programmatically remove salute.You can alter the duration of each salute by using the timeframe home, or alter the duration of all salutes such as this:.tribute(' Celebration has been generated', timeframe: 10000. ).// Persisent salute.salute(' Occasion has actually been actually generated', duration: Immensity. ).On Shut Callback.You can easily pass onDismiss and also onAutoClose callbacks. onDismiss obtains shot when either the close button acquires clicked on or the toast is actually swiped. onAutoClose fires when the toast fades away instantly after it's timeout (timeframe prop).salute(' Event has been developed', onDismiss: (t) =&gt console.log( 'Tribute along with i.d. $ t.id has actually been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with id $ t.id has actually been finalized instantly '). ).Computer keyboard focus.You may focus on the salute area through pressing u2325/ alt + T. You can bypass it by offering an assortment of event.code values for every secret.Motivation.sonner - An opinionated toast component for React.