Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute component for Vue. It's a Vue port of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is actually an opinionated tribute component for Vue. It's personalized, however designated by nonpayment. Includes a wipe to dismiss animation.Installation.To begin making use of the library, install it in your job:.pnpm set up vue-sonner.or even.yarn add vue-sonner.Consumption.For Vue 3.
Render a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, toast from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return give: salute. ).Usage Toaster element and also $salute functionality throughout the Vue SFC.
Leave a toast.
Add the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN 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.Nonpayment.Most essential salute. You can individualize it (and every other kind) through passing a possibilities object as the second argument.salute(' Event has actually been created').Along with personalized description:.tribute(' Activity has been created', explanation: 'Monday, January third at 6:00 pm'. ).Results.Provides a checkmark image before the message.toast.success(' Celebration has actually been actually made').Error.Provides a mistake symbol before the information.toast.error(' Event has certainly not been developed').Action.Renders a switch.toast(' Celebration has actually been generated', activity: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Begins in a packing state and also will definitely upgrade instantly after the assurance fixes or even falls short.You may pass a function to the success/error information to incorporate the result/error of the pledge.toast.promise(() =&gt brand new Guarantee(( fix) =&gt setTimeout( fix, 2000)), loading: 'Filling',.excellence: (information: any kind of) =&gt 'Excellence',.error: (data: any type of) =&gt 'Inaccuracy'. ).Custom Element.You can pass a Vue Part as the very first disagreement instead of a string to render customized Part while preserving nonpayment designing. You can make use of the brainless variation below for a custom-made, unstyled tribute.Customization.Brainless.You may use toast.custom to leave an unstyled toast with personalized jsx while sustaining the functions.Style.You can alter the motif making use of the style prop. Default style is light.Posture.You can modify the placement by means of the position uphold on the element. Default is top-right.
Grown.Salutes can easily likewise be expanded by default through the increase uphold. You may also change the volume of visible tributes which is 3 by default.Styling for all salutes.You can style your toasts internationally along with the toastOptions prop in the Toaster oven element.Styling for individual toast.toast(' Activity has actually been actually generated', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Include a close button to all salutes that reveals on hover by adding the closeButton prop.Rich shades.You can produce error and also results state more vivid by incorporating the richColors set.Customized made up for.Countered from the sides of the display.Programmatically remove salute.To clear away a tribute programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually developed').toast.dismiss( toastId).You may additionally utilize the dismiss technique without the i.d. to put away all toasts.toast.dismiss().Programmatically remove salute.You can easily change the period of each toast by utilizing the period property, or alter the period of all tributes similar to this:.tribute(' Event has actually been actually produced', length: 10000. ).// Persisent tribute.salute(' Event has been developed', timeframe: Infinity. ).On Close Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss receives axed when either the near button acquires clicked on or the toast is swiped. onAutoClose fires when the tribute fades away instantly after it is actually timeout (duration set).tribute(' Activity has actually been created', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with id $ t.id has actually been closed immediately '). ).Key-board concentration.You can concentrate on the toast aspect through pushing u2325/ alt + T. You can easily override it through delivering an assortment of event.code market values for every key.Inspiration.sonner - An opinionated salute element for React.