.An opinionated toast element for Vue. It is actually a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated salute element for Vue. It is actually customizable, but designated through nonpayment. Includes a wipe to disregard animation.Setup.To begin making use of the library, mount it in your venture:.pnpm put up vue-sonner.or.anecdote add vue-sonner.Usage.For Vue 3.
Make a toast.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster).return give: tribute. ).Use Toaster oven component and also $tribute feature throughout the Vue SFC.
Render a tribute.
Include the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Hyperlink.EMS model.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.Nonpayment.A lot of fundamental tribute. You may tailor it (as well as some other kind) through passing a possibilities item as the 2nd disagreement.toast(' Celebration has been actually generated').Along with customized description:.salute(' Event has been produced', explanation: 'Monday, January 3rd at 6:00 pm'. ).Success.Leaves a checkmark symbol facing the information.toast.success(' Celebration has been generated').Mistake.Renders a mistake image facing the notification.toast.error(' Celebration has not been produced').Action.Provides a button.tribute(' Activity has been created', activity: tag: 'Undo',.onClick: () => console.log(' Undo'). ).Promise.Starts in a packing state and also will upgrade instantly after the guarantee settles or neglects.You can pass a feature to the success/error messages to incorporate the result/error of the guarantee.toast.promise(() => brand new Assurance(( fix) => setTimeout( fix, 2000)), filling: 'Loading',.effectiveness: (information: any type of) => 'Excellence',.inaccuracy: (data: any type of) => 'Inaccuracy'. ).Custom Part.You can easily pass a Vue Part as the first argument instead of a string to provide custom-made Part while keeping default designing. You can easily utilize the brainless variation listed below for a personalized, unstyled tribute.Modification.Brainless.You can easily use toast.custom to provide an unstyled salute along with custom jsx while preserving the performance.Style.You can easily alter the concept making use of the style set. Nonpayment concept is actually light.Posture.You may transform the posture via the placement uphold on the element. Default is top-right.
Extended.Toasts may additionally be actually extended by default with the broaden uphold. You may additionally change the volume of apparent tributes which is 3 through default.Styling for all tributes.You may design your salutes around the world along with the toastOptions uphold in the Toaster oven element.Designing for private tribute.toast(' Occasion has been actually developed', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Add a close switch to all tributes that shows on hover through incorporating the closeButton set.Rich colors.You can easily help make mistake and also success state more vivid by adding the richColors prop.Customized countered.Offset coming from the sides of the monitor.Programmatically eliminate tribute.To clear away a tribute programmatically utilize toast.dismiss( i.d.).const toastId = salute(' Occasion has been actually developed').toast.dismiss( toastId).You can easily also make use of the dismiss strategy without the id to dismiss all tributes.toast.dismiss().Programmatically remove salute.You may change the duration of each toast by utilizing the period feature, or alter the length of all toasts like this:.toast(' Occasion has actually been created', length: 10000. ).// Persisent tribute.tribute(' Celebration has been actually produced', length: Immensity. ).On Close Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss gets terminated when either the shut button receives clicked or the salute is swiped. onAutoClose fires when the toast vanishes instantly after it is actually timeout (timeframe prop).toast(' Activity has been produced', onDismiss: (t) => console.log( 'Tribute with i.d. $ t.id has been disregarded '),.onAutoClose: (t) =>console.log( 'Salute with i.d. $ t.id has been actually finalized automatically '). ).Key-board concentration.You may pay attention to the toast aspect by pressing u2325/ alt + T. You can easily bypass it through providing an array of event.code values for every trick.Creativity.sonner - An opinionated tribute part for React.