Sleep

Vue- sonner - Vue.js Feed

.An opinionated toast element for Vue. It's a Vue port of Sonner.Examine.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated toast component for Vue. It's adjustable, yet styled by nonpayment. Possesses a wipe to reject animation.Setup.To begin making use of the collection, mount it in your project:.pnpm mount vue-sonner.or.yarn incorporate vue-sonner.Use.For Vue 3.
Provide a toast.
For Nuxt 3.Define a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster, salute coming from 'vue-sonner'.export nonpayment defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return supply: tribute. ).Usage Toaster oven component as well as $salute feature anywhere in the Vue SFC.
Make a salute.
Include the construct transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...create: transpile: [' vue-sonner'] ).CDN Link.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.Many basic salute. You can individualize it (and some other type) by passing an options things as the 2nd debate.tribute(' Activity has been actually created').Along with personalized summary:.toast(' Activity has been generated', summary: 'Monday, January third at 6:00 pm'. ).Excellence.Leaves a checkmark icon in front of the notification.toast.success(' Event has been generated').Error.Renders an error icon in front of the message.toast.error(' Occasion has actually certainly not been generated').Action.Provides a switch.salute(' Occasion has been generated', action: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Commitment.Starts in a packing condition and also is going to upgrade automatically after the guarantee resolves or fails.You can pass a functionality to the success/error notifications to integrate the result/error of the promise.toast.promise(() =&gt brand new Promise(( fix) =&gt setTimeout( willpower, 2000)), loading: 'Loading',.effectiveness: (information: any kind of) =&gt 'Success',.mistake: (records: any type of) =&gt 'Error'. ).Personalized Part.You can easily pass a Vue Component as the initial argument instead of a cord to render custom Element while keeping nonpayment designing. You can utilize the brainless model listed below for a custom, unstyled tribute.Modification.Brainless.You can easily use toast.custom to provide an unstyled tribute along with personalized jsx while preserving the functions.Concept.You can easily alter the theme using the style set. Nonpayment concept is lightweight.Placement.You can easily modify the setting with the posture prop on the component. Default is top-right.
Grown.Toasts can additionally be actually grown by nonpayment with the broaden uphold. You can easily additionally change the volume of obvious toasts which is actually 3 through nonpayment.Designing for all tributes.You can easily type your tributes around the world with the toastOptions uphold in the Toaster element.Styling for specific tribute.toast(' Celebration has been created', style: history: 'reddish'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Incorporate a near switch to all salutes that reveals on hover by adding the closeButton set.Rich shades.You can create error and also excellence state a lot more vivid through including the richColors prop.Customized made up for.Made up for from the edges of the screen.Programmatically eliminate salute.To take out a toast programmatically make use of toast.dismiss( i.d.).const toastId = tribute(' Occasion has been actually generated').toast.dismiss( toastId).You can additionally use the put away procedure without the i.d. to dismiss all toasts.toast.dismiss().Programmatically clear away tribute.You can easily transform the period of each toast by using the length property, or transform the period of all toasts enjoy this:.tribute(' Activity has been made', duration: 10000. ).// Persisent toast.tribute(' Event has actually been actually produced', period: Immensity. ).On Shut Callback.You can easily pass onDismiss as well as onAutoClose callbacks. onDismiss gets axed when either the near button gets clicked on or even the toast is actually swiped. onAutoClose fires when the salute goes away immediately after it's timeout (period set).tribute(' Activity has been actually created', onDismiss: (t) =&gt console.log( 'Salute along with i.d. $ t.id has been rejected '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with id $ t.id has been actually closed immediately '). ).Computer keyboard focus.You may pay attention to the salute field by pushing u2325/ alt + T. You can easily override it by providing a range of event.code worths for each key.Motivation.sonner - An opinionated salute component for React.