.An opinionated toast element for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated tribute component for Vue. It's personalized, however designated through default. Possesses a wipe to disregard computer animation.Installment.To start using the collection, mount it in your job:.pnpm put in vue-sonner.or.yarn include vue-sonner.Utilization.For Vue 3.
Leave a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back offer: salute. ).Usage Toaster oven component as well as $tribute function anywhere in the Vue SFC.
Make a salute.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.EMS model.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Default.Most fundamental tribute. You can personalize it (and every other style) by passing an alternatives item as the 2nd debate.toast(' Celebration has been actually generated').With custom explanation:.tribute(' Celebration has been actually made', description: 'Monday, January 3rd at 6:00 pm'. ).Success.Leaves a checkmark icon facing the message.toast.success(' Celebration has actually been made').Inaccuracy.Leaves an inaccuracy symbol before the notification.toast.error(' Event has actually not been developed').Action.Presents a button.tribute(' Event has actually been created', activity: label: 'Undo',.onClick: () => console.log(' Undo'). ).Guarantee.Begins in a filling condition and will certainly upgrade immediately after the assurance deals with or fails.You can easily pass a functionality to the success/error information to integrate the result/error of the promise.toast.promise(() => brand new Pledge(( resolve) => setTimeout( fix, 2000)), loading: 'Loading',.success: (records: any) => 'Success',.mistake: (data: any type of) => 'Error'. ).Personalized Component.You can easily pass a Vue Component as the 1st argument rather than a string to provide customized Element while preserving default designing. You can easily utilize the brainless model listed below for a personalized, unstyled tribute.Customization.Brainless.You can make use of toast.custom to make an unstyled tribute with custom-made jsx while sustaining the capability.Theme.You can modify the theme making use of the concept prop. Nonpayment concept is light.Placement.You may change the posture by means of the position prop on the component. Default is top-right.
Expanded.Toasts may likewise be expanded by default with the extend prop. You can easily likewise change the volume of obvious toasts which is 3 through default.Designing for all tributes.You can easily style your toasts internationally along with the toastOptions set in the Toaster component.Designing for individual tribute.tribute(' Celebration has actually been actually produced', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a near switch to all toasts that presents on hover through incorporating the closeButton uphold.Rich different colors.You can easily create error and excellence condition even more vivid by including the richColors uphold.Personalized made up for.Made up for from the edges of the screen.Programmatically clear away toast.To get rid of a toast programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Occasion has been created').toast.dismiss( toastId).You can likewise make use of the put away method without the id to dismiss all toasts.toast.dismiss().Programmatically eliminate salute.You can transform the duration of each toast by utilizing the length property, or modify the timeframe of all toasts similar to this:.salute(' Occasion has been created', period: 10000. ).// Persisent salute.tribute(' Activity has actually been made', duration: Infinity. ).On Close Callback.You may pass onDismiss as well as onAutoClose callbacks. onDismiss obtains discharged when either the close switch obtains clicked on or the toast is actually wiped. onAutoClose fires when the salute fades away instantly after it is actually timeout (duration set).salute(' Celebration has been made', onDismiss: (t) => console.log( 'Salute along with id $ t.id has actually been actually dismissed '),.onAutoClose: (t) =>console.log( 'Toast along with id $ t.id has been closed instantly '). ).Computer keyboard concentration.You may concentrate on the tribute field by pressing u2325/ alt + T. You may override it by giving a collection of event.code market values for every key.Creativity.sonner - An opinionated toast element for React.