Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast 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.Overview.Vue Sonner is actually an opinionated salute part for Vue. It is actually customizable, however designated through nonpayment. Comes with a wipe to disregard computer animation.Installation.To begin making use of the library, mount it in your venture:.pnpm put in vue-sonner.or even.anecdote add vue-sonner.Consumption.For Vue 3.
Render a tribute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, salute coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster).return offer: toast. ).Make use of Toaster component and also $toast feature anywhere in the Vue SFC.
Provide a tribute.
Add the construct transpile for vue-sonner.// nuxt.config.ts.import defineNuxtConfig coming from 'nuxt/config'.export nonpayment defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Hyperlink.Ambulance version.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.Most general toast. You may customize it (and also any other type) through passing a choices object as the second argument.salute(' Activity has been made').With personalized summary:.toast(' Event has been generated', summary: 'Monday, January third at 6:00 pm'. ).Excellence.Renders a checkmark image before the message.toast.success(' Occasion has actually been actually generated').Error.Leaves a mistake symbol facing the information.toast.error(' Occasion has not been created').Activity.Renders a button.toast(' Occasion has actually been made', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a loading condition and will upgrade instantly after the assurance deals with or even fails.You can easily pass a feature to the success/error messages to incorporate the result/error of the guarantee.toast.promise(() =&gt brand new Pledge(( willpower) =&gt setTimeout( fix, 2000)), packing: 'Filling',.effectiveness: (records: any kind of) =&gt 'Effectiveness',.inaccuracy: (data: any sort of) =&gt 'Inaccuracy'. ).Personalized Component.You can easily pass a Vue Element as the first argument as opposed to a strand to leave customized Component while maintaining nonpayment designing. You may utilize the headless model below for a customized, unstyled salute.Modification.Brainless.You can make use of toast.custom to leave an unstyled toast along with customized jsx while preserving the performance.Style.You can easily change the style making use of the motif uphold. Nonpayment concept is light.Position.You may change the setting by means of the placement set on the part. Default is actually top-right.
Broadened.Toasts may additionally be expanded by default with the broaden uphold. You can easily additionally transform the quantity of noticeable toasts which is 3 through default.Designing for all toasts.You can style your toasts internationally along with the toastOptions prop in the Toaster oven element.Designing for private tribute.salute(' Celebration has actually been actually produced', style: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close button.Include a near switch to all tributes that reveals on hover through including the closeButton prop.Rich colors.You may produce mistake and also results state a lot more vibrant through incorporating the richColors prop.Personalized offset.Balanced out from the edges of the display.Programmatically remove toast.To get rid of a salute programmatically make use of toast.dismiss( i.d.).const toastId = toast(' Celebration has been produced').toast.dismiss( toastId).You can easily also use the dismiss procedure without the id to dismiss all tributes.toast.dismiss().Programmatically take out tribute.You may change the timeframe of each tribute by using the length property, or change the duration of all toasts such as this:.tribute(' Occasion has actually been actually developed', length: 10000. ).// Persisent salute.tribute(' Activity has been generated', timeframe: Immensity. ).On Close Callback.You may pass onDismiss and also onAutoClose callbacks. onDismiss receives fired when either the near button obtains clicked or even the salute is actually swiped. onAutoClose fires when the tribute disappears immediately after it is actually timeout (length uphold).tribute(' Event has actually been actually generated', onDismiss: (t) =&gt console.log( 'Salute along with id $ t.id has actually been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Salute along with id $ t.id has been closed instantly '). ).Keyboard concentration.You can focus on the tribute field through pressing u2325/ alt + T. You can easily bypass it through delivering a collection of event.code worths for every key.Motivation.sonner - An opinionated salute element for React.