Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast part for Vue. It is actually a Vue port of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is actually an opinionated tribute element for Vue. It is actually personalized, however designated through default. Features a wipe to reject computer animation.Setup.To start using the library, install it in your project:.pnpm install vue-sonner.or even.yarn include vue-sonner.Usage.For Vue 3.
Provide a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, tribute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster).profits give: toast. ).Make use of Toaster oven component and $tribute feature anywhere in the Vue SFC.
Render a toast.
Include the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Web 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.Nonpayment.The majority of general salute. You may customize it (and any other kind) by passing a choices things as the second argument.salute(' Activity has actually been actually created').Along with custom summary:.toast(' Event has been actually generated', description: 'Monday, January 3rd at 6:00 pm'. ).Success.Renders a checkmark symbol facing the notification.toast.success(' Activity has been created').Mistake.Leaves an inaccuracy symbol facing the notification.toast.error(' Occasion has certainly not been actually produced').Activity.Presents a switch.salute(' Event has actually been made', action: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Promise.Begins in a loading condition and also will certainly upgrade automatically after the promise deals with or fails.You may pass a function to the success/error information to integrate the result/error of the pledge.toast.promise(() =&gt new Pledge(( fix) =&gt setTimeout( fix, 2000)), filling: 'Filling',.success: (data: any type of) =&gt 'Results',.mistake: (records: any type of) =&gt 'Error'. ).Customized Component.You can pass a Vue Element as the 1st argument as opposed to a string to provide customized Component while preserving nonpayment styling. You can use the headless version listed below for a customized, unstyled toast.Personalization.Brainless.You may use toast.custom to make an unstyled tribute with customized jsx while preserving the functions.Theme.You can easily modify the concept making use of the style set. Default theme is lightweight.Posture.You may change the posture by means of the placement uphold on the part. Default is top-right.
Grown.Tributes may likewise be expanded by default through the expand uphold. You may also transform the volume of noticeable toasts which is 3 through nonpayment.Styling for all salutes.You can easily style your salutes internationally with the toastOptions uphold in the Toaster part.Styling for individual tribute.salute(' Occasion has been actually created', design: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Add a near switch to all salutes that reveals on hover through adding the closeButton set.Rich colors.You can produce mistake and also success state a lot more vibrant by incorporating the richColors set.Custom balanced out.Balanced out coming from the sides of the screen.Programmatically eliminate toast.To take out a salute programmatically use toast.dismiss( id).const toastId = toast(' Activity has been actually made').toast.dismiss( toastId).You may additionally utilize the dismiss strategy without the i.d. to put away all tributes.toast.dismiss().Programmatically clear away toast.You may change the period of each tribute by using the length property, or transform the period of all salutes similar to this:.toast(' Occasion has been actually produced', timeframe: 10000. ).// Persisent toast.tribute(' Event has actually been developed', period: Infinity. ).On Close Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss gets fired when either the near button acquires clicked or even the tribute is actually swiped. onAutoClose fires when the toast fades away automatically after it's timeout (period uphold).tribute(' Occasion has been created', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Salute with i.d. $ t.id has actually been actually closed instantly '). ).Key-board concentration.You can pay attention to the salute area by pressing u2325/ alt + T. You may bypass it through providing a selection of event.code worths for each secret.Ideas.sonner - An opinionated tribute element for React.