.An opinionated tribute part for Vue. It is actually a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated toast component for Vue. It's personalized, yet styled through nonpayment. Comes with a swipe to reject animation.Installation.To start utilizing the collection, install it in your job:.pnpm put up vue-sonner.or even.anecdote include vue-sonner.Utilization.For Vue 3.
Make a toast.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, toast from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back offer: toast. ).Use Toaster oven part and also $tribute function throughout the Vue SFC.
Render a salute.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.EMS variation.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.Most general tribute. You can individualize it (as well as some other type) through passing a possibilities object as the second argument.salute(' Celebration has actually been made').With custom-made explanation:.toast(' Activity has been actually developed', explanation: 'Monday, January third at 6:00 pm'. ).Excellence.Leaves a checkmark symbol before the message.toast.success(' Celebration has been actually made').Mistake.Makes an error symbol before the message.toast.error(' Event has actually certainly not been actually developed').Action.Renders a switch.salute(' Celebration has actually been generated', activity: label: 'Undo',.onClick: () => console.log(' Undo'). ).Promise.Starts in a packing condition as well as will update instantly after the commitment resolves or neglects.You can easily pass a function to the success/error notifications to combine the result/error of the guarantee.toast.promise(() => brand-new Promise(( willpower) => setTimeout( willpower, 2000)), packing: 'Loading',.effectiveness: (records: any sort of) => 'Results',.mistake: (data: any type of) => 'Inaccuracy'. ).Customized Component.You may pass a Vue Part as the very first disagreement rather than a strand to leave custom Part while keeping default designing. You can make use of the headless model listed below for a custom-made, unstyled toast.Personalization.Headless.You can easily utilize toast.custom to leave an unstyled salute along with custom jsx while sustaining the performance.Theme.You can modify the style using the style uphold. Nonpayment concept is lightweight.Posture.You can transform the setting by means of the posture set on the part. Default is top-right.
Broadened.Salutes can easily likewise be actually extended by default by means of the extend prop. You may also change the quantity of obvious tributes which is actually 3 by default.Designing for all salutes.You can style your salutes around the world along with the toastOptions set in the Toaster oven element.Designing for individual toast.tribute(' Activity has been made', style: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a close switch to all salutes that shows on hover through including the closeButton set.Rich different colors.You can help make error and also success condition even more multicolored through including the richColors prop.Personalized countered.Countered from the edges of the display.Programmatically take out salute.To clear away a tribute programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Event has actually been actually produced').toast.dismiss( toastId).You may likewise utilize the put away procedure without the i.d. to put away all toasts.toast.dismiss().Programmatically get rid of salute.You can modify the timeframe of each toast by using the period property, or even change the period of all salutes such as this:.salute(' Activity has actually been developed', duration: 10000. ).// Persisent tribute.tribute(' Occasion has been actually produced', length: Immensity. ).On Shut Callback.You may pass onDismiss and also onAutoClose callbacks. onDismiss acquires axed when either the near button acquires clicked on or the toast is actually swiped. onAutoClose fires when the toast goes away automatically after it's timeout (duration set).toast(' Celebration has actually been actually generated', onDismiss: (t) => console.log( 'Toast with i.d. $ t.id has been actually disregarded '),.onAutoClose: (t) =>console.log( 'Tribute with id $ t.id has actually been shut immediately '). ).Key-board emphasis.You can easily pay attention to the toast area through pressing u2325/ alt + T. You can easily bypass it through giving a selection of event.code worths for every secret.Ideas.sonner - An opinionated tribute part for React.