Sleep

Vue- sonner - Vue.js Nourished

.An opinionated toast element for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is actually an opinionated tribute part for Vue. It's personalized, however styled through default. Features a swipe to reject computer animation.Installation.To start using the public library, mount it in your task:.pnpm mount vue-sonner.or.yarn incorporate vue-sonner.Consumption.For Vue 3.
Make a toast.
For Nuxt 3.Determine a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, tribute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back give: toast. ).Make use of Toaster part as well as $toast function throughout the Vue SFC.
Render a toast.
Include the create transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Web link.EMS model.https://cdn.jsdelivr.net/npm/vue-sonner/+esm.UMD model.https://www.unpkg.com/vue-sonner@0.3.1/lib/vue-sonner.umd.cjs.Kinds.Default.Many standard salute. You may customize it (as well as every other style) by passing an options things as the 2nd argument.salute(' Activity has actually been actually generated').Along with personalized summary:.salute(' Activity has actually been developed', description: 'Monday, January 3rd at 6:00 pm'. ).Results.Renders a checkmark image in front of the message.toast.success(' Activity has been actually produced').Inaccuracy.Renders an error icon before the message.toast.error(' Event has actually certainly not been actually created').Action.Presents a button.tribute(' Event has been actually developed', action: tag: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Guarantee.Begins in a loading condition and also will update automatically after the guarantee resolves or even fails.You may pass a feature to the success/error information to integrate the result/error of the commitment.toast.promise(() =&gt new Guarantee(( fix) =&gt setTimeout( resolve, 2000)), packing: 'Filling',.effectiveness: (records: any kind of) =&gt 'Results',.inaccuracy: (records: any sort of) =&gt 'Mistake'. ).Custom Element.You may pass a Vue Element as the first debate instead of a string to leave custom Element while preserving nonpayment styling. You can easily use the headless model below for a customized, unstyled toast.Modification.Headless.You can utilize toast.custom to provide an unstyled salute along with personalized jsx while sustaining the performance.Concept.You can alter the theme using the motif set. Default style is lightweight.Position.You can easily alter the posture by means of the posture prop on the element. Default is actually top-right.
Expanded.Toasts can also be actually increased through default through the increase uphold. You can easily likewise change the volume of visible toasts which is actually 3 by default.Styling for all salutes.You may style your salutes around the world along with the toastOptions set in the Toaster component.Styling for private toast.salute(' Activity has actually been actually generated', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Include a close button to all tributes that presents on hover through including the closeButton set.Rich colours.You may help make error and success condition a lot more multicolored through incorporating the richColors uphold.Custom-made offset.Balanced out from the sides of the display.Programmatically clear away tribute.To clear away a salute programmatically use toast.dismiss( i.d.).const toastId = toast(' Occasion has actually been actually made').toast.dismiss( toastId).You can easily also make use of the put away approach without the i.d. to dismiss all toasts.toast.dismiss().Programmatically remove toast.You can easily change the duration of each tribute by utilizing the period feature, or alter the timeframe of all tributes similar to this:.salute(' Occasion has been produced', period: 10000. ).// Persisent toast.tribute(' Activity has actually been actually developed', duration: Infinity. ).On Shut Callback.You may pass onDismiss and also onAutoClose callbacks. onDismiss receives fired when either the near button gets clicked or even the salute is swiped. onAutoClose fires when the tribute fades away instantly after it's timeout (timeframe set).tribute(' Activity has been made', onDismiss: (t) =&gt console.log( 'Salute along with i.d. $ t.id has been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Salute along with id $ t.id has actually been actually closed automatically '). ).Computer keyboard concentration.You may pay attention to the salute aspect through pushing u2325/ alt + T. You may override it by offering a selection of event.code worths for each and every key.Inspiration.sonner - An opinionated salute part for React.