.An opinionated tribute component for Vue. It is actually a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated toast element for Vue. It is actually customizable, but designated through default. Comes with a swipe to dismiss computer animation.Installation.To start utilizing the collection, install it in your task:.pnpm set up vue-sonner.or.anecdote include vue-sonner.Use.For Vue 3.
Provide a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, tribute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster).profits deliver: salute. ).Use Toaster oven element and $toast function throughout the Vue SFC.
Provide a salute.
Incorporate the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Link.EMS 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.Kinds.Default.Many general toast. You can tailor it (and also every other style) through passing an options things as the 2nd disagreement.tribute(' Celebration has actually been produced').With personalized summary:.toast(' Occasion has actually been made', explanation: 'Monday, January 3rd at 6:00 pm'. ).Results.Makes a checkmark image before the message.toast.success(' Event has actually been actually made').Inaccuracy.Leaves a mistake symbol facing the information.toast.error(' Celebration has actually not been actually developed').Action.Renders a switch.toast(' Event has actually been actually generated', action: label: 'Reverse',.onClick: () => console.log(' Undo'). ).Pledge.Begins in a filling condition and is going to update immediately after the commitment settles or even neglects.You can pass a function to the success/error notifications to incorporate the result/error of the pledge.toast.promise(() => brand new Promise(( fix) => setTimeout( willpower, 2000)), filling: 'Loading',.effectiveness: (information: any kind of) => 'Effectiveness',.error: (information: any type of) => 'Mistake'. ).Custom Element.You may pass a Vue Component as the initial argument rather than a strand to provide custom-made Element while preserving default styling. You can use the brainless version below for a personalized, unstyled tribute.Modification.Headless.You may utilize toast.custom to make an unstyled toast with custom jsx while sustaining the functions.Motif.You can easily modify the style using the concept uphold. Nonpayment style is actually light.Position.You may transform the position with the position prop on the component. Nonpayment is actually top-right.
Extended.Toasts may additionally be extended by default by means of the broaden prop. You can easily likewise transform the volume of noticeable salutes which is actually 3 through nonpayment.Styling for all salutes.You can style your salutes around the globe along with the toastOptions prop in the Toaster oven element.Designing for personal tribute.toast(' Occasion has actually been actually produced', type: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a near button to all toasts that presents on hover through incorporating the closeButton prop.Rich colors.You may produce error and results state more multicolored through incorporating the richColors prop.Custom balanced out.Made up for from the edges of the display screen.Programmatically get rid of toast.To clear away a salute programmatically make use of toast.dismiss( id).const toastId = salute(' Event has actually been generated').toast.dismiss( toastId).You can easily additionally use the put away method without the id to put away all tributes.toast.dismiss().Programmatically take out tribute.You may transform the duration of each tribute by using the length property, or even alter the timeframe of all tributes similar to this:.salute(' Event has been developed', timeframe: 10000. ).// Persisent toast.salute(' Celebration has actually been actually generated', length: Immensity. ).On Shut Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss acquires shot when either the close button acquires clicked on or the salute is swiped. onAutoClose fires when the toast disappears instantly after it's timeout (period uphold).salute(' Celebration has actually been actually developed', onDismiss: (t) => console.log( 'Salute along with i.d. $ t.id has actually been actually disregarded '),.onAutoClose: (t) =>console.log( 'Tribute along with id $ t.id has actually been actually shut immediately '). ).Keyboard focus.You can easily concentrate on the tribute area through pressing u2325/ alt + T. You can easily bypass it through offering a collection of event.code market values for each trick.Ideas.sonner - An opinionated tribute part for React.