Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast component 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 toast element for Vue. It's personalized, however designated through default. Includes a wipe to reject computer animation.Installation.To begin using the public library, install it in your task:.pnpm mount vue-sonner.or.anecdote include vue-sonner.Consumption.For Vue 3.
Make a salute.
For Nuxt 3.Determine a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back give: salute. ).Make use of Toaster oven component as well as $salute function anywhere in the Vue SFC.
Provide a tribute.
Incorporate the develop transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Web link.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Kinds.Default.Many fundamental tribute. You can personalize it (and every other style) by passing an options object as the 2nd argument.toast(' Activity has actually been created').With customized summary:.toast(' Celebration has actually been made', summary: 'Monday, January third at 6:00 pm'. ).Results.Renders a checkmark image in front of the information.toast.success(' Occasion has been produced').Inaccuracy.Makes an error icon before the information.toast.error(' Activity has not been developed').Activity.Provides a button.salute(' Celebration has actually been created', action: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Pledge.Starts in a packing condition and also will improve instantly after the guarantee solves or neglects.You can pass a function to the success/error information to incorporate the result/error of the pledge.toast.promise(() =&gt new Commitment(( fix) =&gt setTimeout( fix, 2000)), filling: 'Filling',.results: (records: any kind of) =&gt 'Success',.error: (information: any kind of) =&gt 'Error'. ).Custom-made Component.You can easily pass a Vue Part as the very first argument as opposed to a strand to make customized Part while sustaining nonpayment designing. You can easily make use of the brainless model listed below for a custom-made, unstyled tribute.Modification.Brainless.You may use toast.custom to make an unstyled toast with personalized jsx while keeping the performance.Concept.You can easily alter the style utilizing the style set. Default motif is actually light.Position.You can easily transform the posture through the posture prop on the part. Default is top-right.
Grown.Tributes can likewise be increased by nonpayment via the expand set. You can easily additionally modify the amount of obvious toasts which is actually 3 through default.Styling for all tributes.You can easily style your salutes globally with the toastOptions prop in the Toaster oven component.Designing for personal salute.toast(' Celebration has been made', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a near button to all salutes that reveals on hover by incorporating the closeButton set.Rich shades.You can easily produce mistake and also success state extra multicolored by incorporating the richColors set.Custom made up for.Offset coming from the edges of the monitor.Programmatically take out salute.To remove a toast programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Celebration has been made').toast.dismiss( toastId).You can easily also utilize the put away technique without the id to dismiss all salutes.toast.dismiss().Programmatically eliminate tribute.You may alter the length of each tribute by using the duration quality, or change the duration of all salutes similar to this:.salute(' Occasion has actually been generated', period: 10000. ).// Persisent salute.salute(' Activity has actually been actually developed', duration: Immensity. ).On Shut Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss obtains shot when either the close switch obtains clicked on or the tribute is swiped. onAutoClose fires when the salute vanishes automatically after it is actually timeout (duration prop).salute(' Occasion has actually been actually generated', onDismiss: (t) =&gt console.log( 'Toast with i.d. $ t.id has actually been actually dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast with i.d. $ t.id has actually been shut instantly '). ).Computer keyboard emphasis.You may concentrate on the salute field by pressing u2325/ alt + T. You may bypass it by giving a variety of event.code values for every trick.Creativity.sonner - An opinionated salute component for React.