Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute component for Vue. It is actually a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated salute part for Vue. It is actually personalized, yet designated by default. Includes a wipe to disregard animation.Setup.To start utilizing the collection, mount it in your job:.pnpm install vue-sonner.or even.yarn include vue-sonner.Utilization.For Vue 3.
Provide a toast.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, toast from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).come back provide: salute. ).Use Toaster element and $toast functionality anywhere in the Vue SFC.
Render a tribute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web 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.Styles.Default.A lot of basic salute. You may individualize it (as well as some other kind) through passing an options things as the second argument.tribute(' Activity has been created').With customized explanation:.toast(' Celebration has actually been produced', summary: 'Monday, January third at 6:00 pm'. ).Excellence.Leaves a checkmark icon in front of the information.toast.success(' Celebration has actually been actually produced').Inaccuracy.Renders a mistake image in front of the information.toast.error(' Celebration has actually certainly not been developed').Action.Presents a button.toast(' Activity has been created', activity: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Guarantee.Begins in a filling condition as well as will definitely update automatically after the promise addresses or even neglects.You may pass a functionality to the success/error notifications to integrate the result/error of the pledge.toast.promise(() =&gt new Assurance(( fix) =&gt setTimeout( resolve, 2000)), filling: 'Packing',.excellence: (data: any kind of) =&gt 'Results',.error: (data: any kind of) =&gt 'Error'. ).Customized Part.You can easily pass a Vue Element as the first disagreement instead of a string to render custom Element while sustaining default styling. You may make use of the headless model listed below for a customized, unstyled salute.Modification.Headless.You can easily utilize toast.custom to render an unstyled toast with custom-made jsx while preserving the capability.Motif.You can alter the concept making use of the theme prop. Nonpayment motif is lightweight.Position.You can transform the placement by means of the placement set on the element. Default is top-right.
Increased.Tributes can also be extended through nonpayment through the increase prop. You can easily also transform the quantity of obvious toasts which is actually 3 through nonpayment.Designing for all tributes.You can design your salutes around the world along with the toastOptions set in the Toaster component.Designing for personal tribute.salute(' Celebration has actually been actually developed', design: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Include a close switch to all tributes that reveals on hover through including the closeButton prop.Rich different colors.You can easily produce inaccuracy as well as effectiveness state a lot more colorful through incorporating the richColors set.Custom-made balanced out.Offset from the sides of the display.Programmatically remove tribute.To get rid of a tribute programmatically utilize toast.dismiss( id).const toastId = tribute(' Occasion has been made').toast.dismiss( toastId).You may additionally utilize the dismiss strategy without the i.d. to dismiss all tributes.toast.dismiss().Programmatically remove toast.You can modify the timeframe of each toast by utilizing the duration feature, or transform the length of all tributes enjoy this:.tribute(' Occasion has actually been produced', length: 10000. ).// Persisent toast.tribute(' Activity has actually been developed', duration: Immensity. ).On Close Callback.You can pass onDismiss as well as onAutoClose callbacks. onDismiss obtains shot when either the shut button receives hit or even the salute is wiped. onAutoClose fires when the tribute fades away instantly after it is actually timeout (length set).salute(' Activity has actually been produced', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has been actually rejected '),.onAutoClose: (t) =&gtconsole.log( 'Tribute along with id $ t.id has been actually closed instantly '). ).Keyboard emphasis.You may concentrate on the tribute aspect through pressing u2325/ alt + T. You can bypass it by providing an array of event.code worths for each trick.Motivation.sonner - An opinionated tribute part for React.