Sleep

Vue- sonner - Vue.js Nourished

.An opinionated tribute element 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 actually an opinionated tribute element for Vue. It is actually customizable, but designated through nonpayment. Comes with a wipe to disregard animation.Installment.To begin making use of the public library, mount it in your project:.pnpm install vue-sonner.or.yarn add vue-sonner.Utilization.For Vue 3.
Make a toast.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).return provide: tribute. ).Usage Toaster oven element and $salute functionality anywhere in the Vue SFC.
Leave a tribute.
Include the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Hyperlink.Ambulance variation.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD variation.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Default.Most simple toast. You can tailor it (and any other kind) by passing an options things as the second argument.toast(' Celebration has actually been actually generated').With customized summary:.salute(' Activity has been developed', description: 'Monday, January 3rd at 6:00 pm'. ).Excellence.Makes a checkmark symbol facing the information.toast.success(' Celebration has been produced').Mistake.Makes a mistake symbol facing the notification.toast.error(' Event has certainly not been produced').Action.Presents a button.toast(' Celebration has actually been actually developed', activity: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Assurance.Begins in a filling condition as well as will certainly upgrade automatically after the commitment settles or fails.You can pass a function to the success/error notifications to include the result/error of the guarantee.toast.promise(() =&gt brand new Promise(( fix) =&gt setTimeout( willpower, 2000)), loading: 'Packing',.effectiveness: (information: any kind of) =&gt 'Results',.inaccuracy: (data: any kind of) =&gt 'Mistake'. ).Personalized Part.You may pass a Vue Component as the very first disagreement as opposed to a cord to make customized Element while sustaining default styling. You can easily use the brainless version listed below for a customized, unstyled salute.Modification.Headless.You may utilize toast.custom to leave an unstyled tribute with custom-made jsx while preserving the capability.Motif.You can change the style using the theme uphold. Nonpayment concept is lightweight.Setting.You can transform the posture through the position uphold on the element. Nonpayment is top-right.
Extended.Toasts can easily additionally be increased through default via the broaden prop. You may likewise transform the quantity of obvious salutes which is actually 3 through nonpayment.Designing for all tributes.You may type your toasts around the globe with the toastOptions set in the Toaster component.Styling for personal toast.toast(' Occasion has actually been produced', type: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Include a close button to all salutes that presents on hover through adding the closeButton set.Rich different colors.You can easily help make error and also success condition a lot more colorful by incorporating the richColors uphold.Custom offset.Made up for from the edges of the display screen.Programmatically take out toast.To clear away a tribute programmatically make use of toast.dismiss( id).const toastId = salute(' Activity has actually been made').toast.dismiss( toastId).You can also use the put away procedure without the id to dismiss all tributes.toast.dismiss().Programmatically take out toast.You can alter the timeframe of each salute by utilizing the length property, or even change the duration of all salutes enjoy this:.salute(' Celebration has actually been developed', period: 10000. ).// Persisent toast.toast(' Event has actually been developed', timeframe: Immensity. ).On Close Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss acquires axed when either the shut button gets clicked or the toast is wiped. onAutoClose fires when the salute vanishes immediately after it's timeout (timeframe prop).tribute(' Occasion has been actually produced', onDismiss: (t) =&gt console.log( 'Salute with id $ t.id has been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with i.d. $ t.id has been closed automatically '). ).Computer keyboard emphasis.You can concentrate on the toast field through pressing u2325/ alt + T. You can easily bypass it by providing a range of event.code values for every secret.Inspiration.sonner - An opinionated salute part for React.