Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute component for Vue. It's a Vue slot of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated tribute component for Vue. It is actually customizable, but styled through nonpayment. Comes with a wipe to disregard computer animation.Installment.To begin making use of the library, install it in your project:.pnpm put up vue-sonner.or even.yarn incorporate vue-sonner.Use.For Vue 3.
Render a toast.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, toast from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).come back provide: toast. ).Use Toaster component and also $salute functionality throughout the Vue SFC.
Provide a tribute.
Add the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Hyperlink.Ambulance model.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.Many simple tribute. You can individualize it (and every other style) through passing a choices object as the 2nd disagreement.salute(' Activity has been generated').With personalized summary:.toast(' Activity has been created', explanation: 'Monday, January 3rd at 6:00 pm'. ).Effectiveness.Provides a checkmark icon before the message.toast.success(' Event has actually been actually produced').Error.Provides a mistake icon in front of the information.toast.error(' Occasion has actually certainly not been developed').Activity.Provides a button.salute(' Celebration has actually been made', activity: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Pledge.Starts in a filling condition and will upgrade immediately after the commitment solves or even falls short.You may pass a function to the success/error information to incorporate the result/error of the promise.toast.promise(() =&gt new Promise(( willpower) =&gt setTimeout( willpower, 2000)), filling: 'Filling',.excellence: (records: any type of) =&gt 'Excellence',.error: (data: any sort of) =&gt 'Mistake'. ).Custom-made Part.You can easily pass a Vue Part as the 1st argument instead of a strand to leave personalized Part while sustaining nonpayment designing. You can easily make use of the headless model below for a custom-made, unstyled toast.Personalization.Headless.You may utilize toast.custom to leave an unstyled toast with customized jsx while preserving the functions.Concept.You may modify the motif utilizing the theme uphold. Default motif is actually light.Posture.You can easily alter the setting through the position prop on the component. Nonpayment is top-right.
Extended.Tributes can additionally be broadened by nonpayment by means of the increase uphold. You can likewise modify the volume of noticeable toasts which is actually 3 by default.Styling for all toasts.You may design your salutes internationally with the toastOptions uphold in the Toaster element.Styling for individual salute.salute(' Occasion has actually been developed', style: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a close button to all tributes that shows on hover by including the closeButton uphold.Rich colours.You can easily create mistake as well as results state even more vibrant by adding the richColors prop.Custom made up for.Balanced out from the sides of the screen.Programmatically clear away tribute.To eliminate a salute programmatically make use of toast.dismiss( id).const toastId = salute(' Event has actually been actually generated').toast.dismiss( toastId).You can easily likewise use the put away approach without the id to dismiss all tributes.toast.dismiss().Programmatically take out salute.You can easily modify the period of each salute by using the duration property, or transform the timeframe of all salutes enjoy this:.tribute(' Event has been created', period: 10000. ).// Persisent tribute.tribute(' Event has actually been made', timeframe: Infinity. ).On Shut Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss acquires axed when either the shut switch obtains clicked or even the tribute is actually swiped. onAutoClose fires when the toast disappears instantly after it is actually timeout (length prop).salute(' Occasion has actually been made', onDismiss: (t) =&gt console.log( 'Tribute along with i.d. $ t.id has been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with i.d. $ t.id has actually been actually finalized immediately '). ).Computer keyboard concentration.You can concentrate on the salute aspect through pushing u2325/ alt + T. You can easily override it by providing a range of event.code values for each and every secret.Ideas.sonner - An opinionated salute component for React.