.An opinionated salute part 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.Introduction.Vue Sonner is actually an opinionated toast part for Vue. It's personalized, however styled by default. Includes a wipe to dismiss animation.Installment.To start making use of the public library, mount it in your project:.pnpm put in vue-sonner.or even.yarn incorporate vue-sonner.Use.For Vue 3.
Provide a tribute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster).return provide: toast. ).Use Toaster oven component as well as $toast functionality throughout the Vue SFC.
Leave a tribute.
Add the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN 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.Kinds.Nonpayment.The majority of simple tribute. You may individualize it (as well as every other kind) by passing an options item as the second debate.salute(' Activity has been actually made').With custom-made description:.toast(' Occasion has actually been made', description: 'Monday, January third at 6:00 pm'. ).Effectiveness.Provides a checkmark image facing the notification.toast.success(' Occasion has been actually generated').Inaccuracy.Leaves an error image before the message.toast.error(' Occasion has certainly not been generated').Activity.Provides a button.toast(' Activity has actually been developed', action: tag: 'Reverse',.onClick: () => console.log(' Undo'). ).Commitment.Starts in a filling condition as well as is going to upgrade instantly after the promise deals with or even fails.You may pass a feature to the success/error messages to include the result/error of the pledge.toast.promise(() => brand new Assurance(( resolve) => setTimeout( resolve, 2000)), loading: 'Filling',.results: (records: any type of) => 'Excellence',.inaccuracy: (information: any kind of) => 'Mistake'. ).Custom Element.You can easily pass a Vue Part as the initial debate rather than a strand to render custom-made Component while sustaining default styling. You can make use of the headless version listed below for a custom-made, unstyled salute.Customization.Brainless.You can easily utilize toast.custom to leave an unstyled salute along with custom jsx while maintaining the functionality.Concept.You can alter the style using the concept uphold. Default style is actually light.Position.You can modify the posture with the position prop on the component. Default is top-right.
Increased.Tributes may likewise be actually extended through default through the grow prop. You may also modify the quantity of apparent tributes which is actually 3 through default.Designing for all toasts.You can easily style your tributes worldwide with the toastOptions set in the Toaster component.Styling for specific tribute.salute(' Event has been developed', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a near button to all salutes that presents on hover by including the closeButton prop.Rich shades.You can produce error and results state a lot more colorful through adding the richColors uphold.Custom-made balanced out.Offset coming from the edges of the display.Programmatically clear away tribute.To clear away a toast programmatically make use of toast.dismiss( id).const toastId = toast(' Activity has actually been produced').toast.dismiss( toastId).You can also make use of the dismiss procedure without the id to dismiss all tributes.toast.dismiss().Programmatically clear away tribute.You can modify the length of each tribute by utilizing the duration quality, or change the period of all toasts enjoy this:.toast(' Event has been created', length: 10000. ).// Persisent toast.tribute(' Event has actually been generated', timeframe: Infinity. ).On Shut Callback.You can pass onDismiss as well as onAutoClose callbacks. onDismiss receives discharged when either the shut button obtains clicked on or even the tribute is actually wiped. onAutoClose fires when the tribute goes away automatically after it's timeout (period uphold).toast(' Activity has actually been actually produced', onDismiss: (t) => console.log( 'Tribute with i.d. $ t.id has been actually rejected '),.onAutoClose: (t) =>console.log( 'Salute along with id $ t.id has actually been closed immediately '). ).Key-board focus.You can easily focus on the salute field through pushing u2325/ alt + T. You may bypass it through supplying a variety of event.code market values for each key.Inspiration.sonner - An opinionated toast component for React.