.An opinionated tribute component for Vue. It is actually a Vue port of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated toast component for Vue. It's customizable, however designated by default. Features a wipe to disregard computer animation.Setup.To begin using the library, mount it in your project:.pnpm mount vue-sonner.or even.anecdote incorporate vue-sonner.Usage.For Vue 3.
Provide a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, tribute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster).come back supply: toast. ).Usage Toaster element and also $tribute functionality anywhere in the Vue SFC.
Provide a tribute.
Include the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.EMS version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Nonpayment.The majority of general tribute. You can personalize it (as well as any other kind) through passing an options things as the 2nd argument.salute(' Occasion has actually been created').With customized summary:.salute(' Occasion has actually been actually created', explanation: 'Monday, January third at 6:00 pm'. ).Excellence.Leaves a checkmark icon facing the information.toast.success(' Occasion has been actually made').Mistake.Leaves an inaccuracy icon facing the message.toast.error(' Activity has certainly not been generated').Activity.Provides a switch.tribute(' Occasion has actually been actually created', action: tag: 'Reverse',.onClick: () => console.log(' Undo'). ).Commitment.Starts in a loading condition and also is going to improve immediately after the assurance resolves or neglects.You can easily pass a function to the success/error messages to combine the result/error of the pledge.toast.promise(() => brand new Pledge(( willpower) => setTimeout( fix, 2000)), filling: 'Filling',.effectiveness: (information: any) => 'Results',.error: (data: any type of) => 'Inaccuracy'. ).Customized Part.You can easily pass a Vue Element as the first debate rather than a string to make personalized Component while maintaining nonpayment styling. You can make use of the headless version below for a personalized, unstyled tribute.Personalization.Brainless.You may make use of toast.custom to make an unstyled salute with custom-made jsx while keeping the performance.Theme.You can modify the concept making use of the concept prop. Nonpayment concept is actually lightweight.Posture.You can transform the setting by means of the position uphold on the component. Default is actually top-right.
Broadened.Toasts may likewise be increased by nonpayment through the broaden set. You can easily likewise transform the volume of noticeable toasts which is 3 by default.Styling for all salutes.You can type your salutes internationally along with the toastOptions set in the Toaster part.Designing for individual toast.toast(' Activity has actually been actually generated', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Add a near button to all salutes that presents on hover by adding the closeButton uphold.Rich different colors.You can easily help make mistake and also results condition even more vivid by incorporating the richColors prop.Custom offset.Made up for coming from the edges of the monitor.Programmatically take out salute.To clear away a salute programmatically make use of toast.dismiss( id).const toastId = toast(' Activity has actually been actually created').toast.dismiss( toastId).You may likewise make use of the put away procedure without the i.d. to put away all tributes.toast.dismiss().Programmatically get rid of salute.You may transform the length of each salute by utilizing the timeframe characteristic, or modify the length of all tributes like this:.tribute(' Occasion has been actually generated', duration: 10000. ).// Persisent salute.tribute(' Celebration has actually been actually developed', timeframe: Infinity. ).On Shut Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss receives fired when either the near button acquires hit or even the tribute is actually swiped. onAutoClose fires when the toast vanishes automatically after it is actually timeout (timeframe prop).salute(' Occasion has been made', onDismiss: (t) => console.log( 'Salute with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =>console.log( 'Toast along with i.d. $ t.id has actually been actually shut immediately '). ).Computer keyboard emphasis.You may concentrate on the salute field through pushing u2325/ alt + T. You may override it by providing an assortment of event.code values for each and every trick.Motivation.sonner - An opinionated tribute component for React.