npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-perfect-scrollbar

v2.0.0

Published

A minimalistic yet powerful Vue.js wrapper for [Perfect Scrollbar](https://perfectscrollbar.com/).

Downloads

164,434

Readme

vue3-perfect-scrollbar

A minimalistic yet powerful Vue.js wrapper for Perfect Scrollbar.

🔍 Considerations Before Using Custom Scrollbars

Before implementing custom scrollbars, consider their potential impact on user experience. Native scrollbar styling, as supported by browsers like Chromeoor Firefox often provides a good balance of customization without sacrificing usability. Check out Chrome's documentation on scrollbar styling to see if it meets your needs. If your project requires precise design alignment that native options can't provide, then vue3-perfect-scrollbar is a solid choice.

📦 Installation

Using npm

npm install vue3-perfect-scrollbar

Using yarn

yarn add vue3-perfect-scrollbar

Using pnpm

pnpm add vue3-perfect-scrollbar

🔌 How to Use

Global Registration

Integrate vue3-perfect-scrollbar globally in your main application file:

import { createApp } from 'vue';
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar';
import 'vue3-perfect-scrollbar/style.css';
import App from './App.vue';

createApp(App).use(PerfectScrollbarPlugin).mount('#app');

Now, you can leverage the plugin in any component:

<PerfectScrollbar>
    <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
    <p> ... and much more content </p>
</PerfectScrollbar>

Customize the container height as needed:

/* example */
.ps {
  height: 400px; /* or max-height: 400px; */
}

Global Options

The install method accepts additional parameters:

app.use(PerfectScrollbarPlugin, {
    componentName: 'Scrollbar'
});

componentName {String}

The name of your global component.

Default: PerfectScrollbar

Local Registration

For local registration, import and declare the component within your Vue component file:

<script setup>
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
</script>

<template>
  <PerfectScrollbar>
    <p>content</p>
  </PerfectScrollbar>
</template>

<style>
@import 'vue3-perfect-scrollbar/style.css';

.ps {
  max-height: 100px; /* or height: 100px; */
}
</style>

⚙️ Props

Customize the Perfect Scrollbar with the following props:

tag?: string;
options?: PerfectScrollbar.Options;

tag? {String}

The tag that will be rendered as the Perfect Scrollbar container.

Default: div

options? {PerfectScrollbar.Options}: Options

Options for the Perfect Scrollbar library.

Explore Perfect Scrollbar options for further customization.

handlers?: string[];
maxScrollbarLength?: number;
minScrollbarLength?: number;
scrollingThreshold?: number;
scrollXMarginOffset?: number;
scrollYMarginOffset?: number;
suppressScrollX?: boolean;
suppressScrollY?: boolean;
swipeEasing?: boolean;
useBothWheelAxes?: boolean;
wheelPropagation?: boolean;
wheelSpeed?: number;

🔄 Events

You can listen to all Perfect Scrollbar events.

Listen to all Perfect Scrollbar events. For a comprehensive list of events, visit Perfect Scrollbar events.

Example

<script setup>
import { PerfectScrollbar } from 'vue3-perfect-scrollbar';

function onScrollEvent(event) {
  console.log(event);
}
</script>

<template>
  <PerfectScrollbar @ps-scroll-y="onScrollEvent">
    <p>content</p>
  </PerfectScrollbar>
</template>

List of Event Keys

'scroll',
'ps-scroll-y',
'ps-scroll-x',
'ps-scroll-up',
'ps-scroll-down',
'ps-scroll-left',
'ps-scroll-right',
'ps-y-reach-start',
'ps-y-reach-end',
'ps-x-reach-start',
'ps-x-reach-end'

🧩 Access to PerfectScrollbar Instance.

To gain direct access to the Perfect Scrollbar instance and leverage its API within your Vue component, you can use the ref attribute.

🔌 Use with Nuxt

Add to your nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['vue3-perfect-scrollbar/nuxt']
});

🆘 Bug Reporting

Found a bug? Here's where to report it:

  • If it's about the vue3-perfect-scrollbar wrapper (like how it works with Vue, or issues with props and events), please report these bugs on our vue3-perfect-scrollbar GitHub repo.

  • If the bug is with the Perfect Scrollbar itself (like problems with how it scrolls or looks), you should report it to the official Perfect Scrollbar repo. Remember, vue3-perfect-scrollbar is just a wrapper to make Perfect Scrollbar work with Vue. It doesn't change how Perfect Scrollbar works. So, if there's something wrong with the scrollbar behavior, the Perfect Scrollbar team needs to know.