Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute element for Vue. It is actually a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated tribute part for Vue. It's personalized, but styled through nonpayment. Possesses a wipe to disregard animation.Setup.To begin using the public library, install it in your task:.pnpm mount vue-sonner.or even.anecdote include vue-sonner.Use.For Vue 3.
Render a salute.
For Nuxt 3.Determine a nuxt plugin.// plugins/sonner. client.ts.import Toaster, salute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return offer: toast. ).Use Toaster oven element and $salute feature anywhere in the Vue SFC.
Render a salute.
Include the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.EMS version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Default.Most basic toast. You can personalize it (and any other style) by passing an options things as the 2nd argument.tribute(' Event has actually been actually made').Along with custom summary:.salute(' Activity has actually been actually developed', summary: 'Monday, January 3rd at 6:00 pm'. ).Effectiveness.Leaves a checkmark image before the information.toast.success(' Occasion has been actually created').Inaccuracy.Provides an inaccuracy icon before the notification.toast.error(' Activity has certainly not been actually developed').Action.Provides a switch.toast(' Event has actually been produced', action: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Pledge.Starts in a packing condition and also will improve immediately after the assurance fixes or falls short.You may pass a functionality to the success/error information to include the result/error of the assurance.toast.promise(() =&gt brand new Assurance(( resolve) =&gt setTimeout( fix, 2000)), packing: 'Filling',.effectiveness: (data: any kind of) =&gt 'Excellence',.error: (data: any sort of) =&gt 'Mistake'. ).Customized Part.You can easily pass a Vue Part as the very first debate rather than a string to make custom Part while sustaining nonpayment styling. You can easily make use of the headless version listed below for a custom, unstyled salute.Customization.Headless.You may make use of toast.custom to render an unstyled salute with personalized jsx while keeping the performance.Theme.You can easily transform the style utilizing the theme set. Default motif is actually light.Position.You may modify the position via the setting prop on the element. Nonpayment is actually top-right.
Expanded.Salutes may additionally be expanded through nonpayment through the extend prop. You can easily likewise alter the amount of obvious salutes which is actually 3 by default.Designing for all salutes.You may type your tributes worldwide along with the toastOptions prop in the Toaster part.Designing for individual salute.toast(' Activity has actually been created', style: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Incorporate a near button to all toasts that reveals on hover through adding the closeButton uphold.Rich colors.You may make inaccuracy and excellence condition extra vibrant by adding the richColors prop.Custom countered.Countered coming from the edges of the display.Programmatically eliminate toast.To clear away a salute programmatically utilize toast.dismiss( i.d.).const toastId = salute(' Event has actually been actually developed').toast.dismiss( toastId).You may additionally use the put away procedure without the i.d. to put away all toasts.toast.dismiss().Programmatically remove toast.You may transform the duration of each toast by using the length characteristic, or modify the length of all toasts similar to this:.tribute(' Event has actually been created', duration: 10000. ).// Persisent tribute.tribute(' Celebration has been created', duration: Immensity. ).On Shut Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss receives discharged when either the close switch receives clicked or the salute is swiped. onAutoClose fires when the tribute fades away instantly after it is actually timeout (length uphold).toast(' Celebration has actually been actually generated', onDismiss: (t) =&gt console.log( 'Toast with id $ t.id has been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute along with i.d. $ t.id has been actually finalized instantly '). ).Computer keyboard emphasis.You may pay attention to the toast field through pushing u2325/ alt + T. You may bypass it through providing a variety of event.code market values for each and every trick.Ideas.sonner - An opinionated toast part for React.

Articles You Can Be Interested In