Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute element for Vue. It's a Vue port of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated salute element for Vue. It's personalized, however styled by nonpayment. Possesses a swipe to disregard computer animation.Installment.To begin utilizing the library, mount it in your project:.pnpm set up vue-sonner.or.yarn include vue-sonner.Use.For Vue 3.
Make a toast.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster).profits deliver: salute. ).Make use of Toaster oven component and $tribute function throughout the Vue SFC.
Make a tribute.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Styles.Default.Most basic toast. You can individualize it (and some other type) through passing an alternatives things as the 2nd disagreement.salute(' Celebration has been actually produced').Along with customized explanation:.tribute(' Celebration has actually been created', description: 'Monday, January third at 6:00 pm'. ).Results.Provides a checkmark icon in front of the information.toast.success(' Event has actually been actually produced').Inaccuracy.Provides an inaccuracy image before the information.toast.error(' Event has actually certainly not been produced').Action.Presents a switch.tribute(' Celebration has been generated', activity: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Begins in a packing condition and also will certainly upgrade instantly after the guarantee deals with or even stops working.You can easily pass a feature to the success/error notifications to integrate the result/error of the guarantee.toast.promise(() =&gt brand-new Pledge(( resolve) =&gt setTimeout( fix, 2000)), loading: 'Filling',.excellence: (records: any type of) =&gt 'Results',.inaccuracy: (data: any kind of) =&gt 'Inaccuracy'. ).Custom-made Component.You may pass a Vue Part as the 1st debate instead of a cord to make personalized Part while sustaining nonpayment styling. You can use the headless version listed below for a personalized, unstyled tribute.Customization.Brainless.You can easily use toast.custom to leave an unstyled tribute along with customized jsx while maintaining the functionality.Style.You can easily change the motif making use of the style set. Default theme is actually lightweight.Placement.You may modify the position by means of the posture set on the component. Default is top-right.
Broadened.Salutes can easily also be broadened by nonpayment by means of the broaden prop. You may likewise alter the amount of visible salutes which is actually 3 through nonpayment.Designing for all salutes.You may style your toasts internationally with the toastOptions uphold in the Toaster oven part.Designing for personal tribute.salute(' Celebration has actually been produced', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a close switch to all toasts that shows on hover through including the closeButton prop.Rich shades.You can create mistake as well as excellence state extra vivid through adding the richColors set.Personalized offset.Made up for from the sides of the display.Programmatically remove salute.To clear away a toast programmatically utilize toast.dismiss( i.d.).const toastId = tribute(' Occasion has actually been developed').toast.dismiss( toastId).You can additionally make use of the dismiss technique without the id to dismiss all toasts.toast.dismiss().Programmatically take out toast.You can modify the period of each salute by utilizing the duration attribute, or even transform the duration of all toasts like this:.salute(' Event has actually been actually generated', period: 10000. ).// Persisent salute.salute(' Celebration has actually been generated', duration: Immensity. ).On Close Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss acquires fired when either the shut switch receives hit or the toast is actually swiped. onAutoClose fires when the toast fades away immediately after it is actually timeout (duration uphold).tribute(' Celebration has been created', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has actually been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with i.d. $ t.id has been finalized instantly '). ).Keyboard focus.You can easily focus on the toast aspect by pushing u2325/ alt + T. You can override it by giving an array of event.code market values for each key.Motivation.sonner - An opinionated tribute part for React.