Sleep

Vue- sonner - Vue.js Feed

.An opinionated tribute element for Vue. It is actually a Vue port of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Introduction.Vue Sonner is an opinionated salute part for Vue. It's personalized, but designated by nonpayment. Includes a wipe to reject computer animation.Setup.To start using the public library, mount it in your job:.pnpm put in vue-sonner.or.anecdote add vue-sonner.Usage.For Vue 3.
Leave a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back give: toast. ).Usage Toaster part as well as $salute feature anywhere in the Vue SFC.
Provide a salute.
Incorporate the develop transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...construct: 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.Types.Default.Many fundamental toast. You can tailor it (and also every other kind) through passing an options things as the 2nd disagreement.toast(' Celebration has been actually made').With custom summary:.tribute(' Event has actually been developed', summary: 'Monday, January third at 6:00 pm'. ).Effectiveness.Provides a checkmark symbol before the information.toast.success(' Activity has been generated').Inaccuracy.Makes a mistake image facing the message.toast.error(' Activity has not been actually created').Action.Renders a button.toast(' Celebration has actually been developed', activity: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Starts in a loading condition and also will certainly improve instantly after the assurance solves or even fails.You may pass a function to the success/error notifications to combine the result/error of the guarantee.toast.promise(() =&gt new Guarantee(( fix) =&gt setTimeout( fix, 2000)), packing: 'Loading',.excellence: (data: any) =&gt 'Results',.mistake: (records: any) =&gt 'Mistake'. ).Personalized Element.You may pass a Vue Element as the first disagreement as opposed to a string to leave customized Component while sustaining default designing. You may use the brainless version listed below for a personalized, unstyled tribute.Customization.Headless.You can easily make use of toast.custom to provide an unstyled salute with customized jsx while maintaining the functionality.Motif.You can easily modify the style utilizing the motif set. Nonpayment style is lightweight.Position.You can easily transform the setting via the setting prop on the part. Nonpayment is actually top-right.
Grown.Tributes can likewise be broadened by default via the increase set. You can easily additionally change the amount of noticeable tributes which is actually 3 by default.Designing for all toasts.You can easily style your tributes internationally along with the toastOptions prop in the Toaster oven part.Designing for private toast.tribute(' Activity has been made', style: background: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Add a near button to all toasts that shows on hover through adding the closeButton prop.Rich colors.You can produce mistake as well as success condition much more vibrant by incorporating the richColors prop.Customized countered.Made up for from the sides of the display.Programmatically take out tribute.To remove a toast programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Occasion has been created').toast.dismiss( toastId).You can also use the put away technique without the id to put away all toasts.toast.dismiss().Programmatically remove tribute.You may modify the duration of each salute by using the length property, or even change the timeframe of all toasts like this:.salute(' Event has actually been actually developed', period: 10000. ).// Persisent toast.toast(' Activity has actually been actually generated', duration: Immensity. ).On Close Callback.You can easily pass onDismiss and also onAutoClose callbacks. onDismiss obtains shot when either the shut button gets clicked on or even the salute is swiped. onAutoClose fires when the tribute fades away immediately after it is actually timeout (period uphold).salute(' Activity has actually been created', onDismiss: (t) =&gt console.log( 'Toast with i.d. $ t.id has actually been actually dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with id $ t.id has been actually finalized immediately '). ).Keyboard emphasis.You can focus on the toast area through pressing u2325/ alt + T. You can bypass it by providing an array of event.code market values for each key.Motivation.sonner - An opinionated tribute element for React.

Articles You Can Be Interested In