Sleep

Vue- sonner - Vue.js Nourished

.An opinionated toast element for Vue. It is actually a Vue port of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated tribute component for Vue. It is actually customizable, but styled through nonpayment. Possesses a swipe to disregard computer animation.Installation.To start using the public library, mount it in your venture:.pnpm mount vue-sonner.or even.anecdote include vue-sonner.Usage.For Vue 3.
Make a toast.
For Nuxt 3.Determine a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return supply: tribute. ).Usage Toaster element and $salute function anywhere in the Vue SFC.
Provide a toast.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.EMS model.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.Nonpayment.The majority of general salute. You can tailor it (and also some other style) through passing a choices object as the 2nd argument.toast(' Celebration has actually been generated').With personalized explanation:.tribute(' Occasion has been generated', summary: 'Monday, January 3rd at 6:00 pm'. ).Excellence.Makes a checkmark icon facing the message.toast.success(' Celebration has been generated').Mistake.Makes a mistake symbol facing the notification.toast.error(' Celebration has not been generated').Action.Presents a switch.tribute(' Event has been actually made', action: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Starts in a loading state and is going to improve immediately after the promise fixes or falls short.You can easily pass a function to the success/error notifications to integrate the result/error of the assurance.toast.promise(() =&gt new Guarantee(( fix) =&gt setTimeout( willpower, 2000)), packing: 'Loading',.effectiveness: (data: any type of) =&gt 'Success',.mistake: (records: any sort of) =&gt 'Error'. ).Custom-made Part.You can easily pass a Vue Element as the 1st debate instead of a cord to leave personalized Element while keeping default designing. You may make use of the headless version listed below for a personalized, unstyled salute.Modification.Brainless.You may make use of toast.custom to provide an unstyled salute along with custom-made jsx while preserving the functionality.Motif.You may modify the motif making use of the concept prop. Default theme is lightweight.Position.You can easily transform the setting by means of the placement prop on the component. Default is top-right.
Extended.Tributes can easily likewise be actually broadened by nonpayment through the expand prop. You can likewise modify the quantity of obvious tributes which is actually 3 through nonpayment.Designing for all toasts.You can easily style your salutes around the globe with the toastOptions prop in the Toaster element.Styling for individual salute.tribute(' Occasion has actually been made', type: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a close switch to all tributes that reveals on hover through incorporating the closeButton set.Rich colors.You can create mistake as well as results condition even more vibrant through incorporating the richColors prop.Customized balanced out.Made up for from the sides of the screen.Programmatically eliminate salute.To clear away a tribute programmatically use toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually developed').toast.dismiss( toastId).You may also use the dismiss strategy without the id to dismiss all toasts.toast.dismiss().Programmatically remove tribute.You may modify the timeframe of each toast by using the timeframe home, or even change the period of all tributes enjoy this:.toast(' Event has been generated', duration: 10000. ).// Persisent toast.toast(' Celebration has been created', period: Infinity. ).On Close Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss receives fired when either the close button gets clicked or the toast is swiped. onAutoClose fires when the toast fades away automatically after it's timeout (length prop).tribute(' Celebration has actually been actually created', onDismiss: (t) =&gt console.log( 'Tribute with i.d. $ t.id has actually been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Toast with i.d. $ t.id has been finalized instantly '). ).Computer keyboard focus.You can easily concentrate on the tribute area by pressing u2325/ alt + T. You may bypass it through supplying an array of event.code worths for each key.Inspiration.sonner - An opinionated toast part for React.