Sleep

Vue- sonner - Vue.js Supplied

.An opinionated tribute element for Vue. It's a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated tribute part for Vue. It's adjustable, however styled by nonpayment. Comes with a wipe to dismiss animation.Installation.To begin making use of the library, mount it in your project:.pnpm mount vue-sonner.or even.yarn add vue-sonner.Utilization.For Vue 3.
Render a tribute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, tribute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).profits give: toast. ).Use Toaster oven element as well as $tribute functionality throughout the Vue SFC.
Leave a tribute.
Include the develop transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Hyperlink.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.A lot of fundamental tribute. You can easily individualize it (and also every other style) by passing a possibilities item as the 2nd disagreement.salute(' Activity has actually been actually created').Along with custom description:.tribute(' Celebration has actually been developed', explanation: 'Monday, January 3rd at 6:00 pm'. ).Results.Provides a checkmark icon facing the message.toast.success(' Occasion has been actually developed').Error.Provides an inaccuracy image before the information.toast.error(' Event has not been created').Activity.Provides a switch.toast(' Event has actually been actually made', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Guarantee.Begins in a filling condition and will definitely update immediately after the commitment solves or even fails.You can easily pass a function to the success/error notifications to combine the result/error of the guarantee.toast.promise(() =&gt brand-new Guarantee(( willpower) =&gt setTimeout( willpower, 2000)), filling: 'Packing',.success: (records: any kind of) =&gt 'Results',.mistake: (data: any type of) =&gt 'Mistake'. ).Customized Element.You can easily pass a Vue Part as the 1st debate rather than a strand to make custom-made Element while maintaining default styling. You can use the headless version below for a custom, unstyled tribute.Modification.Brainless.You can use toast.custom to leave an unstyled salute with customized jsx while keeping the functionality.Concept.You can modify the theme using the motif prop. Nonpayment concept is lightweight.Placement.You can easily transform the setting through the placement set on the component. Default is top-right.
Increased.Toasts can easily also be expanded by nonpayment by means of the extend uphold. You can easily also alter the quantity of visible salutes which is actually 3 by default.Styling for all toasts.You can easily type your tributes around the globe with the toastOptions set in the Toaster element.Designing for personal toast.tribute(' Event has actually been developed', design: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a near switch to all toasts that presents on hover through incorporating the closeButton uphold.Rich shades.You may produce mistake and excellence state much more colorful through including the richColors prop.Personalized made up for.Countered from the edges of the screen.Programmatically eliminate tribute.To clear away a tribute programmatically utilize toast.dismiss( id).const toastId = salute(' Event has actually been actually developed').toast.dismiss( toastId).You can easily additionally utilize the dismiss approach without the id to put away all toasts.toast.dismiss().Programmatically clear away tribute.You can transform the length of each toast by using the period property, or even change the length of all salutes similar to this:.salute(' Celebration has actually been actually created', length: 10000. ).// Persisent tribute.tribute(' Activity has been developed', period: Infinity. ).On Shut Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss obtains terminated when either the shut button gets hit or even the tribute is actually wiped. onAutoClose fires when the tribute disappears automatically after it is actually timeout (timeframe uphold).tribute(' Event has been developed', onDismiss: (t) =&gt console.log( 'Tribute along with i.d. $ t.id has actually been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with i.d. $ t.id has been shut automatically '). ).Key-board focus.You can pay attention to the salute field by pushing u2325/ alt + T. You may override it through supplying a range of event.code worths for each trick.Inspiration.sonner - An opinionated salute component for React.