.An opinionated toast element for Vue. It's a Vue slot of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is actually an opinionated tribute element for Vue. It is actually adjustable, yet designated by nonpayment. Comes with a swipe to reject computer animation.Installation.To start utilizing the public library, mount it in your venture:.pnpm install vue-sonner.or.anecdote incorporate vue-sonner.Consumption.For Vue 3.
Leave a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, tribute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster).profits deliver: salute. ).Use Toaster oven element and $toast functionality anywhere in the Vue SFC.
Make a salute.
Incorporate the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Web link.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD variation.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Kinds.Nonpayment.Many fundamental salute. You may tailor it (and also any other style) by passing an options things as the second debate.toast(' Activity has been actually created').With custom description:.toast(' Activity has actually been created', summary: 'Monday, January 3rd at 6:00 pm'. ).Effectiveness.Provides a checkmark image facing the notification.toast.success(' Celebration has actually been produced').Mistake.Makes a mistake icon facing the message.toast.error(' Activity has certainly not been actually created').Activity.Renders a switch.toast(' Celebration has actually been actually generated', action: label: 'Reverse',.onClick: () => console.log(' Undo'). ).Guarantee.Begins in a filling state and is going to upgrade automatically after the assurance addresses or stops working.You may pass a feature to the success/error notifications to combine the result/error of the guarantee.toast.promise(() => brand new Assurance(( resolve) => setTimeout( fix, 2000)), loading: 'Loading',.success: (data: any kind of) => 'Excellence',.mistake: (information: any kind of) => 'Mistake'. ).Personalized Part.You can easily pass a Vue Part as the very first debate rather than a strand to provide custom-made Element while keeping nonpayment styling. You can make use of the brainless version listed below for a customized, unstyled tribute.Personalization.Brainless.You can easily use toast.custom to make an unstyled toast with customized jsx while maintaining the capability.Motif.You may modify the concept utilizing the concept prop. Nonpayment motif is actually light.Posture.You can easily change the posture through the placement uphold on the element. Nonpayment is top-right.
Increased.Toasts can easily additionally be actually extended by nonpayment with the increase uphold. You can likewise alter the quantity of apparent toasts which is 3 by nonpayment.Styling for all tributes.You can design your salutes worldwide along with the toastOptions uphold in the Toaster component.Styling for specific toast.toast(' Celebration has actually been made', type: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a near switch to all salutes that reveals on hover by adding the closeButton set.Rich colors.You may create inaccuracy as well as excellence state much more colorful through adding the richColors prop.Personalized made up for.Offset coming from the edges of the display.Programmatically clear away toast.To clear away a salute programmatically use toast.dismiss( id).const toastId = tribute(' Occasion has been made').toast.dismiss( toastId).You can easily also utilize the put away procedure without the id to dismiss all salutes.toast.dismiss().Programmatically eliminate tribute.You may transform the period of each salute by utilizing the duration attribute, or even transform the timeframe of all tributes like this:.tribute(' Celebration has actually been produced', period: 10000. ).// Persisent toast.salute(' Celebration has been actually produced', period: Infinity. ).On Close Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss acquires terminated when either the near switch obtains hit or the salute is actually swiped. onAutoClose fires when the salute fades away immediately after it's timeout (duration uphold).toast(' Event has been actually produced', onDismiss: (t) => console.log( 'Salute along with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =>console.log( 'Tribute along with i.d. $ t.id has been actually finalized automatically '). ).Key-board focus.You can pay attention to the toast aspect by pushing u2325/ alt + T. You can override it by supplying an array of event.code worths for each and every secret.Creativity.sonner - An opinionated toast element for React.