.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 tribute component for Vue. It's adjustable, but styled through default. Features a wipe to disregard computer animation.Installation.To start making use of the public library, mount it in your project:.pnpm install vue-sonner.or even.yarn incorporate vue-sonner.Usage.For Vue 3.
Render a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, toast coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) => nuxtApp.vueApp.component(' Toaster', Toaster Oven).come back offer: toast. ).Make use of Toaster oven part as well as $tribute function throughout the Vue SFC.
Make a salute.
Include the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...build: transpile: [' vue-sonner'] ).CDN Hyperlink.Ambulance 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.A lot of simple tribute. You may tailor it (as well as any other style) by passing an alternatives item as the 2nd disagreement.tribute(' Occasion has been actually generated').Along with customized explanation:.tribute(' Occasion has been actually created', description: 'Monday, January third at 6:00 pm'. ).Effectiveness.Makes a checkmark icon before the notification.toast.success(' Celebration has actually been generated').Error.Provides a mistake icon before the notification.toast.error(' Activity has actually not been generated').Activity.Renders a switch.salute(' Activity has been developed', action: tag: 'Reverse',.onClick: () => console.log(' Undo'). ).Guarantee.Begins in a loading condition as well as will improve instantly after the guarantee solves or even fails.You can easily pass a function to the success/error information to combine the result/error of the commitment.toast.promise(() => brand new Pledge(( resolve) => setTimeout( willpower, 2000)), packing: 'Loading',.excellence: (data: any type of) => 'Excellence',.mistake: (records: any type of) => 'Error'. ).Custom Component.You may pass a Vue Component as the first disagreement rather than a cord to render custom-made Part while sustaining default designing. You can easily use the headless variation below for a custom, unstyled toast.Personalization.Headless.You can utilize toast.custom to provide an unstyled tribute with personalized jsx while preserving the functionality.Concept.You may change the style making use of the style set. Default theme is lightweight.Position.You can easily alter the setting via the position set on the component. Nonpayment is actually top-right.
Broadened.Tributes can easily likewise be actually increased by default via the expand set. You can easily also transform the quantity of apparent toasts which is 3 by default.Designing for all tributes.You may style your toasts worldwide with the toastOptions uphold in the Toaster oven component.Designing for specific toast.toast(' Occasion has actually been made', type: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Incorporate a near button to all tributes that reveals on hover through incorporating the closeButton uphold.Rich different colors.You can easily create mistake and results state more colorful through including the richColors set.Custom offset.Made up for coming from the sides of the display screen.Programmatically take out tribute.To eliminate a toast programmatically utilize toast.dismiss( id).const toastId = salute(' Event has actually been actually developed').toast.dismiss( toastId).You can likewise make use of the put away technique without the i.d. to put away all salutes.toast.dismiss().Programmatically eliminate tribute.You may modify the period of each salute by using the duration quality, or alter the length of all toasts similar to this:.salute(' Activity has actually been created', timeframe: 10000. ).// Persisent toast.salute(' Activity has actually been actually produced', timeframe: Infinity. ).On Close Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss gets discharged when either the close button receives clicked on or even the salute is actually wiped. onAutoClose fires when the salute disappears instantly after it is actually timeout (length prop).salute(' Celebration has actually been actually made', onDismiss: (t) => console.log( 'Salute with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =>console.log( 'Tribute along with i.d. $ t.id has been closed instantly '). ).Key-board focus.You can pay attention to the salute aspect by pressing u2325/ alt + T. You can override it through giving an assortment of event.code market values for each and every key.Inspiration.sonner - An opinionated salute element for React.