custom-vue-scrollbar is a lightweight (4.5KB gzipped) and high-performance Vue 3 component designed to provide customizable scrollbars while maintaining a native-like scrolling experience. As of version 0.0.8, it is in early development, with an irregular release cadence. It aims to offer advanced features like floating scrollbars (which fix at the bottom of the screen if the container exceeds visible area), toggleable native/simulated scroll modes for diverse use cases (e.g., synchronizing with outer elements), and automatic scrollbar hiding with configurable delay options. A key differentiator is its emphasis on minimal intrusion, few APIs, and direct access to the native scroll element, distinguishing it from libraries that significantly alter native scrolling behavior or introduce complex abstractions like `better-scroll`. It supports TypeScript and prioritizes performance, outperforming older alternatives by optimizing rendering and minimizing JavaScript-level calculations.
npm install custom-vue-scrollbarVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to register and use the CustomScrollbar component, applying necessary styles and accessing the native scroll element via a ref for programmatic scrolling.
Refer to the project's GitHub repository and README for the latest API documentation with each update.
Ensure that the `<custom-scrollbar>` component has defined dimensions, for example, `:style="{ width: '500px', height: '300px' }"`.Access the native scroll element through a template ref, e.g., `const scroll = ref<{ scrollEl: HTMLDivElement }>();` and then `scroll.value.scrollEl.scrollTo(...)`.For global registration, add `app.component(CustomScrollbar.name, CustomScrollbar);` in your `main.ts` file. For local usage, import it and add it to the `components` option of your Vue component.
Ensure the `<custom-scrollbar>` component has fixed `width` and `height` styles applied (e.g., `:style="{ width: '500px', height: '300px' }"`) and verify `import 'custom-vue-scrollbar/dist/style.css';` is present in your entry file.Ensure the component is mounted and the ref (`scrollRef`) is correctly bound to the `<custom-scrollbar>` instance in the template. Always add a null/undefined check before accessing properties, e.g., `if (scrollRef.value?.scrollEl) { ... }`.