The `vue-smooth-scroll` package provides a lightweight, declarative smooth scrolling directive for Vue.js applications. It enables animated scrolling to anchor links within a page with customizable duration and offset. Currently at version 1.0.13, this library appears to be in a stable state with an infrequent release cadence, primarily targeting Vue 2 environments. Its key differentiators include a minimal footprint (under 1KB gzipped), straightforward integration through a global Vue directive, and a focus on simplicity rather than advanced features like scroll spy or complex easing functions. It serves as a practical solution for projects needing basic, reliable scroll-to-anchor functionality without the overhead of more extensive scrolling solutions. The project builds upon the foundations of the `vue-smoothscroll` library, aiming for ease of use and maintenance.
npm install vue-smooth-scrollVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install, import, and globally register `vue-smooth-scroll` as a Vue plugin. It shows basic usage of the `v-smooth-scroll` directive with and without custom options, enabling smooth scrolling to anchor tags within a single-page application.
For Vue 3 projects, investigate if a Vue 3 compatible fork or an alternative smooth scroll library is available. If using Vue 2, ensure `Vue` is globally available or imported correctly before calling `Vue.use()`.
For specific usage or better tree-shaking, consider manually registering the directive on a component basis or using a local directive definition if the library allows it (though this plugin is designed for global use). Alternatively, accept the global registration for simplicity given the library's small size.
Ensure that `v-smooth-scroll` is not applied to elements where router links or other custom navigation logic is already handling the click event. Test thoroughly to avoid unexpected navigation or scrolling behavior.
Ensure `import vueSmoothScroll from 'vue-smooth-scroll'; Vue.use(vueSmoothScroll);` is called before your Vue application mounts.
Make sure Vue itself is imported and globally available (e.g., `import Vue from 'vue';` or via a script tag) before attempting to use `Vue.use()`.