Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute component for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is actually an opinionated toast component for Vue. It is actually customizable, yet designated through nonpayment. Comes with a swipe to disregard animation.Installation.To begin utilizing the collection, install it in your task:.pnpm put up vue-sonner.or.anecdote include vue-sonner.Utilization.For Vue 3.
Leave a tribute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).come back give: tribute. ).Make use of Toaster oven part and also $salute functionality throughout the Vue SFC.
Render a salute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.Ambulance version.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD version.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Styles.Default.Many fundamental toast. You may personalize it (and any other kind) by passing a possibilities item as the 2nd debate.salute(' Activity has been developed').With customized summary:.salute(' Celebration has been actually produced', summary: 'Monday, January 3rd at 6:00 pm'. ).Results.Makes a checkmark icon before the information.toast.success(' Occasion has been created').Inaccuracy.Renders an inaccuracy image in front of the message.toast.error(' Celebration has actually certainly not been actually produced').Action.Provides a button.salute(' Activity has been made', action: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a filling state as well as will definitely upgrade immediately after the guarantee addresses or neglects.You can easily pass a function to the success/error messages to incorporate the result/error of the commitment.toast.promise(() =&gt new Assurance(( resolve) =&gt setTimeout( fix, 2000)), loading: 'Filling',.results: (records: any sort of) =&gt 'Success',.mistake: (information: any kind of) =&gt 'Error'. ).Custom Element.You can easily pass a Vue Part as the very first debate rather than a string to leave custom Part while maintaining default designing. You can easily utilize the headless version listed below for a customized, unstyled toast.Customization.Brainless.You can easily utilize toast.custom to leave an unstyled tribute with customized jsx while maintaining the functions.Theme.You can easily alter the motif using the motif uphold. Nonpayment theme is lightweight.Placement.You may modify the posture via the posture prop on the component. Nonpayment is top-right.
Increased.Toasts can easily additionally be grown by default via the extend set. You can easily additionally alter the quantity of noticeable tributes which is actually 3 through default.Styling for all toasts.You may design your toasts around the world with the toastOptions set in the Toaster oven element.Designing for personal toast.toast(' Occasion has been actually made', design: history: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a near switch to all tributes that shows on hover through adding the closeButton uphold.Rich colors.You can make inaccuracy and also results condition much more vibrant by including the richColors prop.Personalized made up for.Balanced out from the sides of the display screen.Programmatically remove salute.To clear away a tribute programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Celebration has actually been produced').toast.dismiss( toastId).You can easily additionally use the put away approach without the id to put away all salutes.toast.dismiss().Programmatically clear away toast.You can alter the duration of each tribute by using the period feature, or transform the duration of all toasts enjoy this:.toast(' Activity has been actually generated', duration: 10000. ).// Persisent toast.tribute(' Celebration has actually been made', timeframe: Immensity. ).On Close Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss obtains discharged when either the close button obtains hit or even the salute is actually swiped. onAutoClose fires when the tribute goes away immediately after it is actually timeout (length uphold).salute(' Occasion has been actually made', onDismiss: (t) =&gt console.log( 'Toast with id $ t.id has actually been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Toast with id $ t.id has been actually closed immediately '). ).Key-board focus.You can easily concentrate on the toast field through pushing u2325/ alt + T. You can override it by supplying a range of event.code worths for each and every key.Ideas.sonner - An opinionated toast component for React.