Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast element for Vue. It's a Vue slot of Sonner.Sneak peek.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated salute element for Vue. It's personalized, however designated through nonpayment. Possesses a swipe to disregard computer animation.Installment.To start making use of the public library, mount it in your venture:.pnpm mount vue-sonner.or even.anecdote add vue-sonner.Consumption.For Vue 3.
Make a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, tribute from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster Oven).come back provide: tribute. ).Use Toaster oven part as well as $tribute functionality anywhere in the Vue SFC.
Render a toast.
Incorporate the build transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Hyperlink.EMS 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.Kinds.Default.Most basic tribute. You can easily customize it (as well as some other type) by passing an alternatives things as the second disagreement.salute(' Celebration has been actually made').With personalized description:.salute(' Occasion has been actually generated', description: 'Monday, January third at 6:00 pm'. ).Effectiveness.Renders a checkmark image in front of the message.toast.success(' Occasion has been made').Error.Leaves an error icon before the information.toast.error(' Event has certainly not been actually made').Activity.Presents a button.toast(' Celebration has been actually developed', action: label: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a loading state and also will certainly update automatically after the assurance addresses or falls short.You can pass a feature to the success/error information to include the result/error of the pledge.toast.promise(() =&gt brand-new Commitment(( fix) =&gt setTimeout( fix, 2000)), loading: 'Loading',.effectiveness: (information: any type of) =&gt 'Effectiveness',.inaccuracy: (information: any kind of) =&gt 'Inaccuracy'. ).Customized Component.You can easily pass a Vue Part as the 1st debate instead of a strand to make customized Element while keeping nonpayment designing. You can make use of the headless model listed below for a personalized, unstyled salute.Customization.Headless.You can easily utilize toast.custom to provide an unstyled toast with customized jsx while keeping the functionality.Style.You may modify the concept using the style set. Nonpayment style is lightweight.Setting.You can change the setting with the placement uphold on the component. Default is actually top-right.
Increased.Salutes may additionally be actually extended by default via the broaden uphold. You can easily also modify the quantity of apparent tributes which is actually 3 by nonpayment.Styling for all tributes.You can design your salutes around the world with the toastOptions uphold in the Toaster component.Styling for personal toast.toast(' Activity has been actually made', design: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Incorporate a near switch to all tributes that presents on hover through including the closeButton set.Rich colors.You can easily create mistake and success state more vivid through adding the richColors uphold.Custom made up for.Countered coming from the sides of the display screen.Programmatically clear away tribute.To take out a tribute programmatically utilize toast.dismiss( id).const toastId = salute(' Event has been actually made').toast.dismiss( toastId).You can easily additionally make use of the dismiss technique without the i.d. to dismiss all salutes.toast.dismiss().Programmatically eliminate toast.You may change the period of each salute by utilizing the length quality, or transform the timeframe of all salutes enjoy this:.tribute(' Activity has been actually made', timeframe: 10000. ).// Persisent tribute.salute(' Celebration has actually been created', duration: Infinity. ).On Shut Callback.You can pass onDismiss as well as onAutoClose callbacks. onDismiss acquires discharged when either the near button obtains hit or the toast is wiped. onAutoClose fires when the toast disappears immediately after it's timeout (length uphold).toast(' Celebration has been actually developed', onDismiss: (t) =&gt console.log( 'Tribute with id $ t.id has been actually disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Toast with i.d. $ t.id has actually been finalized instantly '). ).Keyboard emphasis.You may concentrate on the tribute area by pushing u2325/ alt + T. You can easily override it by providing a collection of event.code market values for every key.Ideas.sonner - An opinionated toast part for React.