.An opinionated tribute element for Vue. It's a Vue slot of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated tribute element for Vue. It's customizable, but designated through default. Comes with a wipe to dismiss animation.Installment.To begin using the public library, install it in your job:.pnpm put up vue-sonner.or.anecdote add vue-sonner.Utilization.For Vue 3.
Render a salute.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.import Toaster, tribute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster).come back offer: tribute. ).Make use of Toaster element as well as $salute function anywhere in the Vue SFC.
Render a toast.
Incorporate the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN 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.Styles.Default.A lot of essential toast. You may individualize it (and also some other kind) through passing an options object as the 2nd disagreement.salute(' Occasion has actually been produced').With custom-made description:.tribute(' Event has actually been actually made', summary: 'Monday, January third at 6:00 pm'. ).Results.Provides a checkmark symbol facing the information.toast.success(' Occasion has actually been actually created').Error.Renders an inaccuracy icon in front of the message.toast.error(' Occasion has not been actually created').Action.Renders a button.tribute(' Event has actually been actually developed', action: label: 'Undo',.onClick: () => console.log(' Undo'). ).Promise.Starts in a packing state and also will certainly improve immediately after the commitment solves or stops working.You may pass a functionality to the success/error messages to incorporate the result/error of the commitment.toast.promise(() => new Pledge(( willpower) => setTimeout( resolve, 2000)), packing: 'Loading',.excellence: (information: any) => 'Excellence',.mistake: (records: any type of) => 'Error'. ).Custom Element.You may pass a Vue Part as the initial argument rather than a string to provide personalized Element while sustaining default designing. You can easily use the brainless model listed below for a personalized, unstyled tribute.Customization.Headless.You may use toast.custom to provide an unstyled tribute along with customized jsx while keeping the functionality.Style.You can alter the theme utilizing the motif set. Default motif is lightweight.Placement.You can easily alter the setting via the placement uphold on the element. Default is top-right.
Expanded.Toasts may likewise be extended by nonpayment through the increase set. You can easily also modify the amount of obvious toasts which is actually 3 by nonpayment.Styling for all tributes.You can easily type your salutes around the world with the toastOptions uphold in the Toaster oven part.Designing for specific toast.salute(' Celebration has actually been produced', style: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Add a close switch to all tributes that shows on hover through including the closeButton prop.Rich different colors.You may make inaccuracy and effectiveness condition even more colorful by including the richColors uphold.Personalized countered.Countered from the sides of the monitor.Programmatically eliminate toast.To take out a salute programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually produced').toast.dismiss( toastId).You can easily additionally make use of the put away approach without the i.d. to dismiss all salutes.toast.dismiss().Programmatically get rid of tribute.You may alter the duration of each tribute by utilizing the period feature, or even alter the period of all toasts like this:.toast(' Event has been generated', length: 10000. ).// Persisent toast.toast(' Occasion has been actually produced', duration: Infinity. ).On Close Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss acquires shot when either the shut switch acquires clicked or even the salute is wiped. onAutoClose fires when the tribute fades away automatically after it's timeout (length uphold).toast(' Occasion has been actually produced', onDismiss: (t) => console.log( 'Salute with id $ t.id has been rejected '),.onAutoClose: (t) =>console.log( 'Salute with id $ t.id has been actually shut automatically '). ).Key-board focus.You can pay attention to the toast aspect by pushing u2325/ alt + T. You can override it by giving a selection of event.code values for each and every secret.Creativity.sonner - An opinionated salute element for React.