Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute part 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 tribute element for Vue. It is actually personalized, however designated through nonpayment. Possesses a wipe to dismiss animation.Setup.To begin utilizing the public library, install it in your project:.pnpm mount vue-sonner.or even.anecdote add vue-sonner.Usage.For Vue 3.
Render a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).come back give: tribute. ).Usage Toaster element and $salute functionality throughout the Vue SFC.
Render a toast.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Web link.EMS version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Kinds.Nonpayment.The majority of simple salute. You can easily customize it (and also some other kind) through passing a possibilities item as the 2nd debate.toast(' Event has been actually produced').Along with custom-made summary:.tribute(' Occasion has been made', summary: 'Monday, January 3rd at 6:00 pm'. ).Results.Renders a checkmark icon facing the information.toast.success(' Event has been generated').Error.Makes an error icon facing the message.toast.error(' Celebration has actually certainly not been actually generated').Action.Renders a button.tribute(' Activity has been made', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a loading state and will certainly upgrade immediately after the guarantee fixes or even neglects.You can easily pass a feature to the success/error notifications to integrate the result/error of the guarantee.toast.promise(() =&gt brand-new Promise(( resolve) =&gt setTimeout( resolve, 2000)), filling: 'Loading',.results: (data: any kind of) =&gt 'Success',.inaccuracy: (data: any kind of) =&gt 'Mistake'. ).Custom-made Part.You may pass a Vue Component as the 1st disagreement instead of a strand to render personalized Part while sustaining default designing. You can utilize the brainless model listed below for a custom-made, unstyled tribute.Modification.Headless.You may make use of toast.custom to provide an unstyled tribute along with custom jsx while sustaining the performance.Theme.You can easily modify the theme making use of the style prop. Default motif is actually lightweight.Placement.You may modify the placement by means of the posture uphold on the part. Default is actually top-right.
Expanded.Tributes can likewise be grown by nonpayment with the extend prop. You may also transform the quantity of visible salutes which is 3 through default.Styling for all toasts.You can easily type your tributes globally along with the toastOptions uphold in the Toaster part.Designing for individual salute.salute(' Activity has been produced', design: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Include a close button to all salutes that shows on hover by including the closeButton prop.Rich shades.You may produce error and also results state a lot more vivid through adding the richColors prop.Custom made up for.Made up for from the sides of the monitor.Programmatically clear away salute.To remove a salute programmatically use toast.dismiss( i.d.).const toastId = salute(' Celebration has actually been created').toast.dismiss( toastId).You can easily also use the put away approach without the id to put away all salutes.toast.dismiss().Programmatically clear away salute.You can modify the period of each salute by using the timeframe home, or alter the period of all tributes similar to this:.toast(' Event has actually been actually developed', period: 10000. ).// Persisent salute.toast(' Activity has actually been generated', length: Infinity. ).On Shut Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss gets axed when either the close button acquires clicked on or the toast is actually wiped. onAutoClose fires when the toast goes away automatically after it's timeout (length uphold).salute(' Activity has actually been produced', onDismiss: (t) =&gt console.log( 'Salute with i.d. $ t.id has actually been actually dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast with id $ t.id has been actually closed immediately '). ).Key-board concentration.You can focus on the salute area through pressing u2325/ alt + T. You may override it by supplying a variety of event.code market values for each and every secret.Motivation.sonner - An opinionated tribute part for React.