Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute element for Vue. It's a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated toast part for Vue. It's customizable, but styled by nonpayment. Possesses a wipe to reject computer animation.Installation.To start using the collection, install it in your venture:.pnpm install vue-sonner.or.anecdote incorporate vue-sonner.Utilization.For Vue 3.
Leave a toast.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).profits provide: salute. ).Make use of Toaster part and also $tribute function anywhere in the Vue SFC.
Make a toast.
Include the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Web link.EMS version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Types.Nonpayment.Many basic salute. You may tailor it (as well as some other style) through passing an alternatives item as the second disagreement.tribute(' Celebration has actually been produced').Along with customized summary:.toast(' Event has been developed', summary: 'Monday, January third at 6:00 pm'. ).Effectiveness.Makes a checkmark image in front of the notification.toast.success(' Occasion has actually been created').Inaccuracy.Makes a mistake image in front of the information.toast.error(' Activity has actually not been made').Activity.Provides a switch.salute(' Activity has actually been created', activity: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Begins in a filling condition as well as will definitely improve immediately after the assurance settles or stops working.You can pass a functionality to the success/error messages to incorporate the result/error of the commitment.toast.promise(() =&gt brand new Promise(( resolve) =&gt setTimeout( resolve, 2000)), filling: 'Packing',.effectiveness: (data: any) =&gt 'Success',.mistake: (information: any) =&gt 'Mistake'. ).Customized Part.You can easily pass a Vue Component as the first debate instead of a string to leave custom-made Component while preserving nonpayment styling. You may utilize the headless model below for a personalized, unstyled toast.Personalization.Headless.You may utilize toast.custom to render an unstyled toast along with personalized jsx while maintaining the functionality.Concept.You can easily change the motif using the style prop. Nonpayment theme is actually light.Position.You can transform the setting via the posture prop on the element. Nonpayment is top-right.
Expanded.Toasts can likewise be increased by nonpayment with the broaden prop. You can easily likewise change the quantity of noticeable salutes which is 3 through nonpayment.Designing for all tributes.You can design your toasts around the world along with the toastOptions prop in the Toaster component.Styling for individual toast.salute(' Occasion has been actually generated', design: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Add a near button to all tributes that shows on hover by adding the closeButton prop.Rich shades.You can easily produce error and effectiveness state more vibrant by adding the richColors set.Custom made up for.Made up for coming from the sides of the display.Programmatically remove salute.To eliminate a salute programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Celebration has actually been developed').toast.dismiss( toastId).You may likewise use the put away approach without the id to dismiss all salutes.toast.dismiss().Programmatically remove tribute.You can change the period of each tribute by using the period property, or modify the timeframe of all toasts enjoy this:.salute(' Celebration has actually been actually made', timeframe: 10000. ).// Persisent salute.tribute(' Event has actually been actually developed', period: Immensity. ).On Close Callback.You can easily pass onDismiss and onAutoClose callbacks. onDismiss gets discharged when either the close button gets hit or the salute is swiped. onAutoClose fires when the toast goes away automatically after it's timeout (period uphold).tribute(' Activity has been actually made', onDismiss: (t) =&gt console.log( 'Salute with i.d. $ t.id has actually been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with id $ t.id has been actually finalized automatically '). ).Computer keyboard focus.You may pay attention to the toast field by pressing u2325/ alt + T. You may override it through delivering an array of event.code worths for each secret.Inspiration.sonner - An opinionated toast component for React.