Sleep

Vue- sonner - Vue.js Supplied

.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.Introduction.Vue Sonner is actually an opinionated salute component for Vue. It's personalized, however designated through default. Comes with a wipe to dismiss computer animation.Installation.To begin making use of the library, install it in your task:.pnpm put up vue-sonner.or.anecdote add vue-sonner.Use.For Vue 3.
Make a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).profits supply: tribute. ).Make use of Toaster oven part as well as $tribute function anywhere in the Vue SFC.
Leave a tribute.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Hyperlink.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.Styles.Nonpayment.Most essential salute. You may personalize it (and also every other kind) through passing an options things as the second argument.salute(' Event has been made').With customized summary:.salute(' Occasion has actually been developed', explanation: 'Monday, January 3rd at 6:00 pm'. ).Effectiveness.Leaves a checkmark image in front of the information.toast.success(' Occasion has been actually created').Error.Provides a mistake icon facing the message.toast.error(' Celebration has actually not been actually made').Activity.Provides a switch.toast(' Celebration has been produced', activity: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Pledge.Begins in a filling condition as well as is going to upgrade automatically after the guarantee resolves or neglects.You can easily pass a functionality to the success/error notifications to combine the result/error of the pledge.toast.promise(() =&gt new Guarantee(( willpower) =&gt setTimeout( fix, 2000)), packing: 'Filling',.success: (records: any) =&gt 'Effectiveness',.inaccuracy: (data: any) =&gt 'Inaccuracy'. ).Custom-made Element.You can easily pass a Vue Part as the initial debate as opposed to a string to provide custom Part while sustaining default styling. You can easily utilize the brainless version below for a custom, unstyled tribute.Customization.Brainless.You can utilize toast.custom to provide an unstyled salute along with customized jsx while maintaining the performance.Concept.You may change the theme using the concept uphold. Nonpayment motif is lightweight.Setting.You can modify the setting with the placement prop on the component. Default is actually top-right.
Grown.Tributes can easily also be actually expanded through nonpayment through the extend uphold. You can likewise transform the volume of visible tributes which is 3 through nonpayment.Styling for all toasts.You can easily style your salutes globally with the toastOptions uphold in the Toaster part.Styling for personal salute.salute(' Celebration has actually been made', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Add a near switch to all salutes that presents on hover by incorporating the closeButton set.Rich different colors.You can produce inaccuracy and success state a lot more vibrant through including the richColors set.Custom balanced out.Countered coming from the sides of the monitor.Programmatically take out salute.To take out a tribute programmatically make use of toast.dismiss( id).const toastId = salute(' Activity has actually been produced').toast.dismiss( toastId).You can easily also utilize the put away method without the id to dismiss all salutes.toast.dismiss().Programmatically eliminate salute.You can easily transform the length of each salute by utilizing the duration feature, or transform the timeframe of all tributes such as this:.tribute(' Event has been made', duration: 10000. ).// Persisent tribute.toast(' Occasion has actually been actually generated', timeframe: Infinity. ).On Shut Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss receives fired when either the near button receives clicked or even the salute is actually wiped. onAutoClose fires when the toast disappears automatically after it's timeout (duration prop).tribute(' Celebration has actually been produced', onDismiss: (t) =&gt console.log( 'Toast along with i.d. $ t.id has actually been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Tribute along with id $ t.id has been shut automatically '). ).Computer keyboard concentration.You may pay attention to the toast aspect through pressing u2325/ alt + T. You can bypass it through supplying a range of event.code worths for every key.Ideas.sonner - An opinionated salute component for React.

Articles You Can Be Interested In