Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute component for Vue. It's a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated toast component for Vue. It is actually adjustable, yet designated by nonpayment. Includes a wipe to reject animation.Setup.To start making use of the public library, install it in your task:.pnpm mount vue-sonner.or.yarn add vue-sonner.Use.For Vue 3.
Render a toast.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, tribute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster).profits offer: tribute. ).Usage Toaster element and $tribute functionality throughout the Vue SFC.
Make a toast.
Include the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Web link.Ambulance 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.Types.Default.Most simple salute. You may tailor it (as well as any other style) by passing a choices things as the second debate.salute(' Event has been produced').Along with custom-made description:.toast(' Activity has been actually developed', description: 'Monday, January third at 6:00 pm'. ).Effectiveness.Makes a checkmark symbol in front of the information.toast.success(' Activity has been created').Inaccuracy.Leaves an inaccuracy image before the message.toast.error(' Celebration has actually not been produced').Action.Renders a button.toast(' Activity has been actually developed', activity: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Commitment.Begins in a filling condition as well as will definitely update automatically after the promise deals with or even falls short.You can pass a function to the success/error information to include the result/error of the pledge.toast.promise(() =&gt brand new Guarantee(( resolve) =&gt setTimeout( resolve, 2000)), filling: 'Packing',.success: (data: any kind of) =&gt 'Success',.mistake: (data: any kind of) =&gt 'Error'. ).Personalized Part.You may pass a Vue Element as the initial disagreement instead of a string to render custom Part while sustaining nonpayment styling. You can use the brainless variation listed below for a personalized, unstyled salute.Personalization.Brainless.You can easily make use of toast.custom to render an unstyled salute with custom-made jsx while maintaining the capability.Motif.You can transform the style making use of the concept prop. Nonpayment concept is actually light.Position.You can easily modify the placement via the setting uphold on the component. Default is actually top-right.
Broadened.Salutes can easily also be actually extended through default via the grow set. You can easily also modify the quantity of obvious tributes which is 3 through default.Styling for all salutes.You can easily type your toasts around the world along with the toastOptions uphold in the Toaster part.Styling for individual salute.tribute(' Event has actually been actually generated', type: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a near button to all toasts that reveals on hover by adding the closeButton set.Rich shades.You may make inaccuracy as well as effectiveness state even more vivid by including the richColors uphold.Custom-made offset.Made up for coming from the edges of the monitor.Programmatically get rid of tribute.To get rid of a toast programmatically use toast.dismiss( id).const toastId = tribute(' Occasion has been actually made').toast.dismiss( toastId).You can easily additionally utilize the put away method without the i.d. to put away all toasts.toast.dismiss().Programmatically clear away toast.You can easily change the length of each tribute by using the timeframe quality, or even transform the period of all toasts similar to this:.salute(' Event has been actually created', timeframe: 10000. ).// Persisent salute.tribute(' Celebration has been generated', length: Infinity. ).On Shut Callback.You may pass onDismiss as well as onAutoClose callbacks. onDismiss obtains shot when either the close button gets clicked on or even the toast is swiped. onAutoClose fires when the salute disappears automatically after it's timeout (duration prop).salute(' Celebration has been created', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with i.d. $ t.id has been closed immediately '). ).Key-board emphasis.You can focus on the toast area through pushing u2325/ alt + T. You may override it by supplying a collection of event.code values for each key.Motivation.sonner - An opinionated toast part for React.