Sleep

Vue- sonner - Vue.js Nourished

.An opinionated tribute element for Vue. It's a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is actually an opinionated salute component for Vue. It's personalized, however designated through nonpayment. Features a swipe to dismiss computer animation.Installment.To begin utilizing the library, mount it in your venture:.pnpm put in vue-sonner.or even.yarn add vue-sonner.Use.For Vue 3.
Provide a toast.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return provide: tribute. ).Use Toaster oven part as well as $tribute feature throughout the Vue SFC.
Render a toast.
Add the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...construct: 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.Kinds.Nonpayment.Most standard tribute. You can customize it (as well as some other style) through passing a choices object as the 2nd disagreement.tribute(' Celebration has actually been actually created').With customized summary:.tribute(' Celebration has been made', explanation: 'Monday, January 3rd at 6:00 pm'. ).Excellence.Provides a checkmark image in front of the notification.toast.success(' Celebration has been actually developed').Error.Renders an error image before the message.toast.error(' Event has certainly not been actually developed').Action.Renders a button.salute(' Event has been actually generated', action: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Promise.Begins in a loading state as well as will certainly improve automatically after the guarantee addresses or even neglects.You can pass a feature to the success/error notifications to incorporate the result/error of the commitment.toast.promise(() =&gt brand-new Pledge(( fix) =&gt setTimeout( fix, 2000)), filling: 'Filling',.success: (records: any) =&gt 'Effectiveness',.inaccuracy: (data: any sort of) =&gt 'Error'. ).Customized Component.You can pass a Vue Part as the very first argument instead of a strand to make custom Element while maintaining default styling. You can make use of the brainless version listed below for a custom-made, unstyled toast.Personalization.Brainless.You can easily use toast.custom to make an unstyled tribute along with custom jsx while preserving the capability.Concept.You can alter the theme making use of the concept set. Nonpayment motif is lightweight.Posture.You can easily change the placement with the placement set on the component. Nonpayment is top-right.
Broadened.Tributes may likewise be actually broadened by nonpayment through the grow prop. You can easily also alter the volume of apparent tributes which is 3 by nonpayment.Styling for all salutes.You may design your salutes globally along with the toastOptions prop in the Toaster oven part.Styling for specific salute.toast(' Occasion has actually been developed', type: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Include a close switch to all toasts that presents on hover by including the closeButton uphold.Rich colors.You can easily produce inaccuracy and results state a lot more vibrant by incorporating the richColors set.Personalized balanced out.Offset coming from the sides of the monitor.Programmatically take out tribute.To remove a toast programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Event has been actually developed').toast.dismiss( toastId).You may additionally utilize the put away method without the i.d. to put away all salutes.toast.dismiss().Programmatically clear away tribute.You may change the timeframe of each toast by utilizing the length quality, or modify the length of all tributes like this:.tribute(' Occasion has been made', duration: 10000. ).// Persisent salute.tribute(' Celebration has been generated', duration: Immensity. ).On Close Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss gets shot when either the close switch acquires hit or even the toast is actually wiped. onAutoClose fires when the salute vanishes instantly after it's timeout (timeframe set).salute(' Celebration has actually been produced', onDismiss: (t) =&gt console.log( 'Tribute with i.d. $ t.id has actually been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Salute along with i.d. $ t.id has actually been shut instantly '). ).Key-board focus.You may concentrate on the salute field through pushing u2325/ alt + T. You may override it through delivering a range of event.code values for every trick.Creativity.sonner - An opinionated tribute component for React.