Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute element for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated salute component for Vue. It is actually personalized, yet styled by default. Features a swipe to reject computer animation.Installment.To begin making use of the public library, install it in your task:.pnpm install vue-sonner.or.yarn include vue-sonner.Use.For Vue 3.
Render a tribute.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).come back give: salute. ).Use Toaster oven component and $toast feature anywhere in the Vue SFC.
Leave a salute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.Ambulance 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.Types.Nonpayment.Most general toast. You can easily personalize it (as well as some other style) through passing an alternatives object as the 2nd disagreement.toast(' Celebration has been made').With customized summary:.salute(' Occasion has actually been actually generated', explanation: 'Monday, January 3rd at 6:00 pm'. ).Success.Makes a checkmark symbol before the notification.toast.success(' Activity has actually been actually created').Inaccuracy.Provides an error icon facing the notification.toast.error(' Activity has not been created').Activity.Presents a button.toast(' Event has actually been actually produced', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Promise.Starts in a packing state and is going to update instantly after the pledge deals with or even fails.You may pass a functionality to the success/error information to combine the result/error of the guarantee.toast.promise(() =&gt brand new Pledge(( willpower) =&gt setTimeout( willpower, 2000)), packing: 'Packing',.excellence: (data: any sort of) =&gt 'Success',.error: (information: any type of) =&gt 'Error'. ).Custom Part.You can pass a Vue Component as the initial disagreement instead of a string to make custom-made Component while maintaining nonpayment styling. You can use the brainless version listed below for a customized, unstyled toast.Personalization.Headless.You can easily use toast.custom to provide an unstyled tribute with custom jsx while keeping the functions.Concept.You may transform the style making use of the style set. Nonpayment theme is actually light.Posture.You can easily modify the position via the posture set on the element. Nonpayment is top-right.
Extended.Tributes may likewise be actually broadened through nonpayment via the extend uphold. You can easily likewise modify the volume of apparent tributes which is 3 by default.Styling for all toasts.You can type your salutes worldwide with the toastOptions uphold in the Toaster element.Styling for private salute.toast(' Celebration has actually been actually made', type: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Include a close button to all tributes that presents on hover through incorporating the closeButton uphold.Rich colors.You may create error as well as excellence condition extra colorful through including the richColors prop.Custom-made balanced out.Offset coming from the edges of the display screen.Programmatically take out salute.To take out a toast programmatically utilize toast.dismiss( i.d.).const toastId = toast(' Activity has been created').toast.dismiss( toastId).You can likewise make use of the dismiss approach without the i.d. to dismiss all tributes.toast.dismiss().Programmatically clear away toast.You can easily transform the length of each salute by utilizing the length characteristic, or modify the length of all tributes such as this:.salute(' Celebration has been actually generated', duration: 10000. ).// Persisent salute.salute(' Activity has actually been produced', length: Immensity. ).On Close Callback.You can easily pass onDismiss and also onAutoClose callbacks. onDismiss obtains terminated when either the near switch obtains clicked or even the salute is swiped. onAutoClose fires when the salute vanishes instantly after it's timeout (length uphold).salute(' Activity has actually been developed', onDismiss: (t) =&gt console.log( 'Tribute with id $ t.id has been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Toast with i.d. $ t.id has actually been closed immediately '). ).Computer keyboard focus.You may concentrate on the toast field by pressing u2325/ alt + T. You may bypass it through providing a range of event.code values for each key.Motivation.sonner - An opinionated toast component for React.