Sleep

Vue- sonner - Vue.js Supplied

.An opinionated tribute part for Vue. It's a Vue slot of Sonner.Preview.https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a41c-88a60c0e2800.mp4.Intro.Vue Sonner is an opinionated tribute part for Vue. It is actually customizable, but styled by nonpayment. Possesses a wipe to dismiss computer animation.Installation.To start utilizing the public library, install it in your project:.pnpm mount vue-sonner.or.anecdote add vue-sonner.Use.For Vue 3.
Provide a toast.
For Nuxt 3.Describe a nuxt plugin.// plugins/sonner. client.ts.import Toaster oven, tribute coming from 'vue-sonner'.export default defineNuxtPlugin(( nuxtApp) =&gt nuxtApp.vueApp.component(' Toaster oven', Toaster).come back deliver: tribute. ).Use Toaster part as well as $toast functionality anywhere in the Vue SFC.
Render a toast.
Include the construct transpile for vue-sonner.// nuxt.config.ts.bring in defineNuxtConfig coming from 'nuxt/config'.export default defineNuxtConfig( ...develop: transpile: [' vue-sonner'] ).CDN Hyperlink.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.Styles.Nonpayment.Most standard salute. You may individualize it (as well as every other type) through passing a choices object as the second debate.tribute(' Celebration has been actually made').With customized summary:.tribute(' Occasion has been actually created', summary: 'Monday, January third at 6:00 pm'. ).Results.Leaves a checkmark icon in front of the message.toast.success(' Event has been actually produced').Mistake.Leaves a mistake symbol facing the information.toast.error(' Event has actually not been produced').Action.Provides a button.salute(' Event has been created', activity: tag: 'Undo',.onClick: () =&gt console.log(' Undo'). ).Assurance.Begins in a loading condition as well as will definitely improve instantly after the pledge resolves or even stops working.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( fix, 2000)), packing: 'Loading',.excellence: (data: any type of) =&gt 'Effectiveness',.inaccuracy: (records: any sort of) =&gt 'Error'. ).Personalized Element.You can pass a Vue Part as the initial debate as opposed to a string to render custom-made Part while preserving nonpayment styling. You may make use of the brainless variation below for a custom-made, unstyled toast.Personalization.Brainless.You may make use of toast.custom to render an unstyled salute with custom-made jsx while keeping the performance.Theme.You can easily modify the motif making use of the motif prop. Default style is light.Placement.You may transform the placement by means of the posture prop on the element. Nonpayment is top-right.
Broadened.Tributes can easily also be expanded through default through the expand prop. You can additionally transform the volume of obvious toasts which is actually 3 through default.Designing for all salutes.You can type your salutes around the globe along with the toastOptions uphold in the Toaster element.Styling for personal salute.toast(' Occasion has been produced', style: background: 'red'.,.className: 'my-toast',.descriptionClassName: 'my-toast-description'. ).Near button.Incorporate a near button to all salutes that presents on hover through incorporating the closeButton prop.Rich colours.You can produce inaccuracy as well as excellence state much more colorful through including the richColors uphold.Customized made up for.Offset from the edges of the display screen.Programmatically get rid of salute.To take out a salute programmatically utilize toast.dismiss( i.d.).const toastId = tribute(' Event has been actually produced').toast.dismiss( toastId).You may additionally use the put away strategy without the i.d. to dismiss all tributes.toast.dismiss().Programmatically clear away salute.You can easily alter the timeframe of each salute by utilizing the period home, or even transform the period of all salutes enjoy this:.salute(' Celebration has been created', period: 10000. ).// Persisent tribute.tribute(' Event has actually been made', duration: Immensity. ).On Close Callback.You may pass onDismiss and onAutoClose callbacks. onDismiss acquires terminated when either the close button gets hit or even the tribute is actually swiped. onAutoClose fires when the tribute goes away automatically after it's timeout (period set).tribute(' Event has actually been produced', onDismiss: (t) =&gt console.log( 'Salute along with i.d. $ t.id has been dismissed '),.onAutoClose: (t) =&gtconsole.log( 'Tribute with i.d. $ t.id has actually been finalized instantly '). ).Keyboard emphasis.You can pay attention to the toast aspect by pushing u2325/ alt + T. You can easily override it through offering a selection of event.code values for each secret.Inspiration.sonner - An opinionated toast element for React.