Sleep

Vue- sonner - Vue.js Nourished

.An opinionated toast part for Vue. It is actually a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is actually an opinionated salute part for Vue. It is actually adjustable, but styled through default. Features a wipe to dismiss animation.Installment.To begin using the library, mount it in your project:.pnpm set up vue-sonner.or.yarn add vue-sonner.Consumption.For Vue 3.
Make a salute.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.import Toaster, toast coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return offer: tribute. ).Usage Toaster oven element as well as $toast feature anywhere in the Vue SFC.
Render a salute.
Include the create transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export nonpayment defineNuxtConfig( ...develop: 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.Kinds.Default.A lot of simple tribute. You may personalize it (and also every other type) by passing a choices object as the second disagreement.salute(' Occasion has actually been actually produced').With custom-made summary:.toast(' Occasion has actually been actually made', explanation: 'Monday, January third at 6:00 pm'. ).Effectiveness.Renders a checkmark icon facing the information.toast.success(' Activity has actually been actually generated').Mistake.Provides an inaccuracy image in front of the message.toast.error(' Event has actually certainly not been developed').Activity.Presents a switch.salute(' Activity has been created', action: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Pledge.Begins in a packing state and also is going to update automatically after the assurance solves or even falls short.You can pass a feature to the success/error messages to include the result/error of the guarantee.toast.promise(() =&gt brand-new Commitment(( willpower) =&gt setTimeout( willpower, 2000)), packing: 'Loading',.effectiveness: (information: any) =&gt 'Excellence',.inaccuracy: (data: any) =&gt 'Error'. ).Custom Element.You can pass a Vue Component as the 1st debate rather than a cord to leave custom-made Element while maintaining nonpayment styling. You may use the brainless version listed below for a customized, unstyled toast.Modification.Headless.You can make use of toast.custom to render an unstyled salute with custom-made jsx while maintaining the functions.Motif.You can change the theme making use of the concept prop. Default style is actually light.Placement.You can easily alter the position with the setting set on the element. Nonpayment is top-right.
Broadened.Salutes may also be actually increased by default through the extend prop. You can easily likewise modify the quantity of visible tributes which is actually 3 by default.Designing for all toasts.You may design your tributes internationally along with the toastOptions prop in the Toaster oven component.Designing for specific salute.toast(' Event has actually been made', design: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Close switch.Add a close switch to all tributes that reveals on hover by adding the closeButton prop.Rich shades.You can help make error and also excellence condition even more colorful through including the richColors set.Personalized offset.Offset coming from the edges of the display.Programmatically take out salute.To take out a tribute programmatically make use of toast.dismiss( id).const toastId = toast(' Celebration has been made').toast.dismiss( toastId).You can easily additionally make use of the dismiss approach without the i.d. to dismiss all toasts.toast.dismiss().Programmatically take out tribute.You may modify the timeframe of each toast by utilizing the length attribute, or even modify the timeframe of all tributes such as this:.tribute(' Occasion has been produced', length: 10000. ).// Persisent salute.tribute(' Celebration has actually been generated', duration: Immensity. ).On Close Callback.You can pass onDismiss and onAutoClose callbacks. onDismiss gets discharged when either the shut button gets clicked on or the tribute is wiped. onAutoClose fires when the toast vanishes instantly after it's timeout (duration set).tribute(' Celebration has been actually generated', onDismiss: (t) =&gt console.log( 'Toast with id $ t.id has actually been actually dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Salute along with i.d. $ t.id has been actually shut automatically '). ).Keyboard focus.You can easily concentrate on the salute area through pushing u2325/ alt + T. You can override it through giving a collection of event.code values for each secret.Creativity.sonner - An opinionated toast part for React.