Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute element for Vue. It is actually a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated toast component for Vue. It is actually adjustable, but designated through nonpayment. Possesses a swipe to disregard computer animation.Installation.To begin making use of the public library, install it in your job:.pnpm install vue-sonner.or.anecdote include vue-sonner.Use.For Vue 3.
Make a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, salute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).come back provide: salute. ).Usage Toaster oven component and $tribute feature anywhere in the Vue SFC.
Make a tribute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Web link.EMS 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.Styles.Nonpayment.A lot of fundamental tribute. You may customize it (and any other style) by passing an options things as the 2nd disagreement.tribute(' Activity has been generated').Along with customized explanation:.salute(' Activity has been actually generated', explanation: 'Monday, January 3rd at 6:00 pm'. ).Effectiveness.Renders a checkmark icon facing the notification.toast.success(' Occasion has been actually generated').Error.Leaves an inaccuracy symbol in front of the message.toast.error(' Celebration has not been produced').Activity.Renders a switch.salute(' Occasion has been actually generated', action: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a filling state and also will definitely improve automatically after the commitment resolves or even neglects.You may pass a functionality to the success/error information to include the result/error of the guarantee.toast.promise(() =&gt brand new Pledge(( fix) =&gt setTimeout( willpower, 2000)), packing: 'Packing',.success: (data: any) =&gt 'Effectiveness',.error: (records: any type of) =&gt 'Error'. ).Personalized Element.You can pass a Vue Element as the very first disagreement rather than a string to leave personalized Part while maintaining nonpayment designing. You can utilize the headless variation below for a custom, unstyled salute.Modification.Brainless.You can use toast.custom to make an unstyled salute along with customized jsx while sustaining the capability.Concept.You can transform the motif making use of the theme uphold. Default concept is lightweight.Setting.You may change the posture through the posture set on the element. Nonpayment is top-right.
Broadened.Tributes can easily additionally be extended by nonpayment by means of the increase set. You may also transform the quantity of visible toasts which is actually 3 by default.Designing for all toasts.You can easily type your toasts around the globe along with the toastOptions prop in the Toaster oven component.Designing for personal salute.tribute(' Event has been actually developed', style: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a close button to all salutes that shows on hover by incorporating the closeButton set.Rich different colors.You may create error and also success state a lot more colorful by incorporating the richColors prop.Customized balanced out.Balanced out coming from the sides of the screen.Programmatically remove tribute.To eliminate a toast programmatically use toast.dismiss( i.d.).const toastId = toast(' Event has been made').toast.dismiss( toastId).You can also utilize the put away technique without the id to put away all toasts.toast.dismiss().Programmatically eliminate toast.You can easily change the length of each tribute by using the period home, or change the period of all toasts like this:.tribute(' Celebration has actually been generated', period: 10000. ).// Persisent salute.tribute(' Occasion has actually been actually developed', timeframe: Immensity. ).On Shut Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss receives terminated when either the shut button receives clicked or even the toast is swiped. onAutoClose fires when the tribute disappears immediately after it is actually timeout (timeframe prop).tribute(' Celebration has actually been actually generated', onDismiss: (t) =&gt console.log( 'Tribute along with id $ t.id has been actually dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with id $ t.id has been closed instantly '). ).Key-board concentration.You may concentrate on the tribute field by pushing u2325/ alt + T. You can override it through offering a collection of event.code market values for every secret.Inspiration.sonner - An opinionated tribute element for React.