Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute part for Vue. It is actually a Vue port of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated toast part for Vue. It is actually adjustable, but styled through nonpayment. Features a swipe to dismiss animation.Installment.To begin utilizing the library, mount it in your job:.pnpm put in vue-sonner.or.yarn incorporate vue-sonner.Utilization.For Vue 3.
Leave a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, toast coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).return provide: salute. ).Use Toaster component and also $toast functionality anywhere in the Vue SFC.
Make a tribute.
Add the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Web link.Ambulance 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.Types.Default.A lot of standard salute. You can tailor it (and also every other type) by passing a choices item as the 2nd argument.tribute(' Activity has actually been developed').With custom-made description:.tribute(' Occasion has been actually produced', summary: 'Monday, January 3rd at 6:00 pm'. ).Results.Makes a checkmark symbol before the notification.toast.success(' Occasion has been produced').Mistake.Renders an error icon facing the message.toast.error(' Event has not been produced').Action.Provides a button.salute(' Occasion has been actually developed', activity: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Begins in a loading condition and also will definitely improve automatically after the pledge resolves or even stops working.You can pass a functionality to the success/error notifications to incorporate the result/error of the promise.toast.promise(() =&gt brand-new Assurance(( fix) =&gt setTimeout( resolve, 2000)), packing: 'Loading',.excellence: (data: any kind of) =&gt 'Results',.inaccuracy: (records: any) =&gt 'Inaccuracy'. ).Custom Component.You may pass a Vue Part as the 1st debate as opposed to a string to make custom Part while keeping nonpayment styling. You may make use of the headless variation listed below for a custom-made, unstyled tribute.Modification.Brainless.You may use toast.custom to provide an unstyled salute with custom jsx while preserving the capability.Concept.You can change the motif making use of the theme uphold. Default theme is actually light.Position.You can easily change the placement by means of the posture prop on the element. Default is top-right.
Grown.Salutes may also be grown through nonpayment through the expand uphold. You may also transform the quantity of noticeable salutes which is actually 3 by default.Designing for all salutes.You can design your salutes globally along with the toastOptions prop in the Toaster oven element.Designing for private salute.toast(' Celebration has been produced', design: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a close switch to all toasts that shows on hover by adding the closeButton prop.Rich shades.You may help make error and also results state much more vivid through adding the richColors prop.Customized made up for.Offset coming from the sides of the display.Programmatically take out toast.To clear away a tribute programmatically make use of toast.dismiss( id).const toastId = salute(' Activity has been produced').toast.dismiss( toastId).You may additionally make use of the dismiss strategy without the id to dismiss all salutes.toast.dismiss().Programmatically clear away tribute.You can easily modify the timeframe of each salute by using the duration attribute, or transform the timeframe of all tributes like this:.tribute(' Event has actually been developed', timeframe: 10000. ).// Persisent salute.salute(' Event has been actually made', timeframe: Immensity. ).On Close Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss gets axed when either the close button gets clicked or the tribute is actually swiped. onAutoClose fires when the tribute goes away automatically after it's timeout (duration prop).toast(' Celebration has been actually developed', onDismiss: (t) =&gt console.log( 'Salute with i.d. $ t.id has actually been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute along with id $ t.id has been actually closed instantly '). ).Keyboard emphasis.You can easily pay attention to the salute area by pressing u2325/ alt + T. You can easily bypass it through supplying a range of event.code values for each secret.Ideas.sonner - An opinionated tribute element for React.

Articles You Can Be Interested In