Sleep

Vue- sonner - Vue.js Feed

.An opinionated salute component for Vue. It's a Vue port of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Overview.Vue Sonner is an opinionated tribute part for Vue. It is actually customizable, yet styled by nonpayment. Possesses a wipe to dismiss animation.Installation.To start utilizing the collection, install it in your job:.pnpm mount vue-sonner.or even.yarn include vue-sonner.Usage.For Vue 3.
Leave a salute.
For Nuxt 3.Specify a nuxt plugin.// plugins/sonner. client.ts.bring in Toaster oven, salute coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster', Toaster Oven).return give: salute. ).Use Toaster oven component as well as $tribute feature anywhere in the Vue SFC.
Render a toast.
Incorporate the construct transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig from 'nuxt/config'.export default defineNuxtConfig( ...construct: transpile: [' vue-sonner'] ).CDN Web link.EMS 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 fundamental toast. You may customize it (and some other type) through passing a choices item as the second debate.toast(' Activity has actually been actually created').Along with custom summary:.salute(' Event has actually been actually created', summary: 'Monday, January 3rd at 6:00 pm'. ).Results.Makes a checkmark symbol facing the message.toast.success(' Occasion has actually been actually created').Error.Provides an inaccuracy icon in front of the notification.toast.error(' Celebration has actually not been produced').Action.Provides a button.tribute(' Activity has been actually developed', activity: label: 'Reverse',.onClick: () =&gt console.log(' Undo'). ).Assurance.Starts in a loading state and will definitely upgrade instantly after the promise deals with or even falls short.You can pass a function to the success/error notifications to include the result/error of the promise.toast.promise(() =&gt brand new Assurance(( willpower) =&gt setTimeout( willpower, 2000)), filling: 'Filling',.results: (information: any kind of) =&gt 'Excellence',.inaccuracy: (records: any kind of) =&gt 'Inaccuracy'. ).Custom-made Element.You can pass a Vue Element as the 1st debate as opposed to a string to render custom Component while keeping nonpayment designing. You can easily make use of the headless model below for a custom, unstyled salute.Modification.Brainless.You can utilize toast.custom to render an unstyled toast with custom jsx while sustaining the capability.Motif.You can easily alter the motif making use of the theme prop. Default motif is actually light.Setting.You can change the posture through the position set on the element. Nonpayment is actually top-right.
Expanded.Toasts may likewise be grown through default with the broaden set. You can also change the volume of visible salutes which is 3 by nonpayment.Styling for all toasts.You may type your salutes internationally along with the toastOptions set in the Toaster oven part.Designing for private salute.salute(' Occasion has been generated', design: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near switch.Include a close switch to all salutes that presents on hover through incorporating the closeButton prop.Rich colours.You may help make error as well as results condition extra vivid through adding the richColors prop.Customized balanced out.Offset from the edges of the display.Programmatically take out salute.To get rid of a salute programmatically use toast.dismiss( id).const toastId = toast(' Event has been created').toast.dismiss( toastId).You can easily likewise utilize the put away technique without the id to dismiss all salutes.toast.dismiss().Programmatically eliminate salute.You may alter the length of each salute by utilizing the length property, or modify the duration of all salutes like this:.toast(' Celebration has been created', period: 10000. ).// Persisent toast.salute(' Event has been developed', timeframe: Infinity. ).On Close Callback.You can pass onDismiss and also onAutoClose callbacks. onDismiss receives axed when either the shut switch receives clicked on or even the toast is actually wiped. onAutoClose fires when the salute fades away instantly after it's timeout (length prop).toast(' Celebration has been actually made', onDismiss: (t) =&gt console.log( 'Tribute with id $ t.id has actually been disregarded '),.onAutoClose: (t) =&gtconsole.log( 'Toast along with id $ t.id has actually been shut automatically '). ).Computer keyboard concentration.You can focus on the tribute field by pressing u2325/ alt + T. You can easily override it by giving a collection of event.code market values for each trick.Ideas.sonner - An opinionated salute part for React.