.An opinionated toast element for Vue. It's 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 salute part for Vue. It is actually customizable, but styled by nonpayment. Includes a swipe to reject animation.Setup.To start using the collection, install it in your venture:.pnpm put up vue-sonner.or even.yarn incorporate vue-sonner.Use.For Vue 3.
Provide a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, salute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).profits give: toast. ).Make use of Toaster element as well as $salute feature anywhere in the Vue SFC.
Leave a tribute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Link.Ambulance variation.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.A lot of standard tribute. You can individualize it (as well as every other kind) by passing an options things as the second argument.toast(' Occasion has been produced').With customized explanation:.salute(' Celebration has been developed', explanation: 'Monday, January third at 6:00 pm'. ).Effectiveness.Leaves a checkmark icon before the information.toast.success(' Occasion has actually been actually developed').Inaccuracy.Renders an error icon facing the information.toast.error(' Celebration has not been made').Action.Presents a button.tribute(' Activity has been made', action: label: 'Reverse',.onClick: () => console.log(' Undo'). ).Commitment.Starts in a filling condition as well as is going to update automatically after the pledge resolves or stops working.You can pass a functionality to the success/error information to combine the result/error of the commitment.toast.promise(() => brand-new Pledge(( willpower) => setTimeout( willpower, 2000)), loading: 'Filling',.success: (information: any type of) => 'Success',.inaccuracy: (records: any sort of) => 'Inaccuracy'. ).Custom Part.You may pass a Vue Part as the very first argument as opposed to a string to leave personalized Component while preserving default designing. You can make use of the brainless variation below for a personalized, unstyled toast.Personalization.Brainless.You may utilize toast.custom to make an unstyled salute along with personalized jsx while keeping the functionality.Concept.You can easily change the theme using the concept uphold. Default motif is actually lightweight.Setting.You can easily alter the placement through the position prop on the component. Default is actually top-right.
Broadened.Salutes can easily also be actually extended by nonpayment with the grow prop. You can likewise modify the quantity of obvious toasts which is actually 3 through default.Styling for all salutes.You may type your tributes around the globe with the toastOptions set in the Toaster oven component.Styling for private toast.tribute(' Occasion has actually been actually made', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Incorporate a near button to all salutes that shows on hover through adding the closeButton set.Rich colors.You can produce mistake and also excellence state more vivid by adding the richColors uphold.Personalized offset.Countered coming from the edges of the display.Programmatically take out toast.To get rid of a toast programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Event has actually been developed').toast.dismiss( toastId).You can additionally utilize the put away technique without the i.d. to put away all toasts.toast.dismiss().Programmatically remove toast.You may change the period of each toast by using the duration property, or even alter the timeframe of all toasts enjoy this:.salute(' Celebration has actually been actually made', period: 10000. ).// Persisent tribute.salute(' Event has been actually produced', duration: Infinity. ).On Shut Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss receives discharged when either the close button acquires clicked on or even the tribute is actually swiped. onAutoClose fires when the toast vanishes automatically after it's timeout (duration prop).toast(' Celebration has been actually produced', onDismiss: (t) => console.log( 'Tribute with id $ t.id has actually been dismissed '),.onAutoClose: (t) =>console.log( 'Tribute along with id $ t.id has actually been shut instantly '). ).Computer keyboard emphasis.You can easily pay attention to the tribute aspect through pushing u2325/ alt + T. You can bypass it through providing a variety of event.code market values for each and every key.Inspiration.sonner - An opinionated tribute part for React.