Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute component for Vue. It is actually a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated toast component for Vue. It's personalized, yet styled through default. Possesses a wipe to dismiss computer animation.Installment.To begin making use of the public library, mount it in your venture:.pnpm mount vue-sonner.or even.yarn include vue-sonner.Utilization.For Vue 3.
Make a toast.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, tribute from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).come back supply: tribute. ).Usage Toaster component as well as $tribute feature anywhere in the Vue SFC.
Make a salute.
Add the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Hyperlink.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.Kinds.Default.Many standard tribute. You can personalize it (and also every other style) by passing a possibilities things as the second argument.salute(' Activity has actually been actually created').Along with personalized explanation:.salute(' Event has been made', description: 'Monday, January 3rd at 6:00 pm'. ).Excellence.Provides a checkmark icon before the notification.toast.success(' Celebration has been actually generated').Error.Provides an error symbol in front of the message.toast.error(' Celebration has certainly not been actually made').Activity.Renders a switch.tribute(' Event has been generated', activity: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Pledge.Begins in a loading state and will definitely update immediately after the guarantee resolves or even stops working.You can pass a function to the success/error messages to incorporate the result/error of the guarantee.toast.promise(() =&gt brand new Promise(( willpower) =&gt setTimeout( willpower, 2000)), packing: 'Loading',.success: (data: any kind of) =&gt 'Success',.error: (records: any type of) =&gt 'Error'. ).Customized Component.You can easily pass a Vue Part as the initial debate as opposed to a strand to leave personalized Component while maintaining default designing. You can easily use the headless variation below for a custom-made, unstyled salute.Personalization.Headless.You may utilize toast.custom to render an unstyled tribute along with customized jsx while maintaining the functions.Theme.You can easily transform the concept making use of the motif prop. Default concept is light.Posture.You can easily change the position via the posture set on the component. Nonpayment is top-right.
Increased.Toasts can easily additionally be actually broadened by default by means of the grow uphold. You can easily additionally transform the amount of apparent salutes which is 3 by nonpayment.Designing for all tributes.You can style your salutes internationally with the toastOptions prop in the Toaster part.Styling for specific salute.toast(' Occasion has been actually generated', type: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a near button to all salutes that shows on hover through incorporating the closeButton prop.Rich colours.You may create error and results condition more multicolored through including the richColors set.Personalized balanced out.Made up for coming from the edges of the display screen.Programmatically clear away salute.To get rid of a toast programmatically use toast.dismiss( i.d.).const toastId = toast(' Celebration has actually been created').toast.dismiss( toastId).You can easily additionally utilize the dismiss technique without the i.d. to put away all tributes.toast.dismiss().Programmatically take out tribute.You may transform the timeframe of each tribute by utilizing the length characteristic, or even transform the timeframe of all tributes like this:.toast(' Occasion has been developed', timeframe: 10000. ).// Persisent toast.tribute(' Event has actually been actually made', length: Immensity. ).On Shut Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss gets fired when either the near button acquires hit or the salute is wiped. onAutoClose fires when the tribute goes away instantly after it is actually timeout (duration uphold).toast(' Occasion has actually been actually made', onDismiss: (t) =&gt console.log( 'Toast along with id $ t.id has actually been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with i.d. $ t.id has been closed automatically '). ).Computer keyboard concentration.You can concentrate on the salute aspect by pressing u2325/ alt + T. You can bypass it by delivering an array of event.code worths for every trick.Creativity.sonner - An opinionated salute component for React.