Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast 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 actually an opinionated toast part for Vue. It is actually adjustable, however designated through nonpayment. Features a wipe to dismiss computer animation.Setup.To start using the library, mount it in your task:.pnpm set up vue-sonner.or.anecdote incorporate vue-sonner.Utilization.For Vue 3.
Render a tribute.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, tribute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).profits offer: tribute. ).Use Toaster oven element as well as $salute functionality anywhere in the Vue SFC.
Provide a salute.
Add the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Web link.Ambulance 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.Kinds.Default.A lot of general toast. You may personalize it (and also every other kind) through passing a choices object as the 2nd debate.tribute(' Occasion has been actually created').Along with custom description:.toast(' Activity has been actually produced', description: 'Monday, January 3rd at 6:00 pm'. ).Excellence.Leaves a checkmark icon facing the notification.toast.success(' Occasion has actually been created').Inaccuracy.Leaves a mistake image before the notification.toast.error(' Event has certainly not been generated').Activity.Presents a switch.salute(' Activity has been actually created', action: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Starts in a loading condition as well as will update instantly after the promise resolves or even neglects.You can easily pass a function to the success/error messages to incorporate the result/error of the pledge.toast.promise(() =&gt brand-new Promise(( willpower) =&gt setTimeout( willpower, 2000)), packing: 'Filling',.success: (data: any kind of) =&gt 'Excellence',.inaccuracy: (records: any type of) =&gt 'Error'. ).Custom Component.You may pass a Vue Part as the 1st disagreement rather than a strand to leave custom Part while maintaining nonpayment styling. You may make use of the headless version listed below for a personalized, unstyled salute.Personalization.Brainless.You may make use of toast.custom to render an unstyled tribute with custom-made jsx while keeping the functions.Motif.You can easily transform the style using the motif uphold. Nonpayment style is actually lightweight.Position.You may transform the setting by means of the posture prop on the element. Nonpayment is top-right.
Extended.Toasts can easily also be grown through nonpayment via the extend uphold. You can also modify the amount of obvious salutes which is 3 by default.Designing for all toasts.You may design your toasts around the world with the toastOptions prop in the Toaster oven element.Designing for specific salute.toast(' Activity has actually been actually made', type: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Include a near switch to all tributes that reveals on hover through incorporating the closeButton prop.Rich different colors.You can create error as well as success condition even more colorful by including the richColors set.Custom-made made up for.Made up for from the sides of the screen.Programmatically remove salute.To get rid of a toast programmatically use toast.dismiss( i.d.).const toastId = salute(' Occasion has been actually produced').toast.dismiss( toastId).You may likewise use the put away technique without the i.d. to dismiss all tributes.toast.dismiss().Programmatically clear away tribute.You can easily modify the timeframe of each salute by using the duration characteristic, or even alter the timeframe of all toasts enjoy this:.toast(' Occasion has been produced', length: 10000. ).// Persisent salute.toast(' Celebration has actually been actually produced', duration: Immensity. ).On Close Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss receives terminated when either the close button receives clicked or the tribute is wiped. onAutoClose fires when the salute fades away immediately after it is actually timeout (length uphold).salute(' Event has been made', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with id $ t.id has actually been closed automatically '). ).Key-board focus.You can pay attention to the salute area through pressing u2325/ alt + T. You may override it by delivering an assortment of event.code values for each key.Motivation.sonner - An opinionated tribute component for React.