Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-perfect-scrollbar

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-perfect-scrollbar

A react wrapper for perfect-scrollbar

  • 1.5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
197K
increased by14.56%
Maintainers
1
Weekly downloads
 
Created

What is react-perfect-scrollbar?

react-perfect-scrollbar is a React wrapper for the Perfect Scrollbar library, which provides a customizable and performant scrollbar for web applications. It allows developers to easily integrate custom scrollbars into their React components, enhancing the user experience with smooth scrolling and various customization options.

What are react-perfect-scrollbar's main functionalities?

Basic Usage

This code demonstrates the basic usage of react-perfect-scrollbar. It wraps a div containing some content with the PerfectScrollbar component, enabling custom scrolling for the content.

import React from 'react';
import PerfectScrollbar from 'react-perfect-scrollbar';
import 'react-perfect-scrollbar/dist/css/styles.css';

const MyComponent = () => (
  <PerfectScrollbar>
    <div style={{ height: '200px' }}>
      <p>Your content here...</p>
    </div>
  </PerfectScrollbar>
);

export default MyComponent;

Custom Styling

This example shows how to apply custom styling to the scrollbar. By adding a custom CSS class to the PerfectScrollbar component, you can style the scrollbar to match your application's design.

import React from 'react';
import PerfectScrollbar from 'react-perfect-scrollbar';
import 'react-perfect-scrollbar/dist/css/styles.css';
import './customScrollbar.css';

const MyComponent = () => (
  <PerfectScrollbar className="custom-scrollbar">
    <div style={{ height: '200px' }}>
      <p>Your content here...</p>
    </div>
  </PerfectScrollbar>
);

export default MyComponent;

Event Handling

This code demonstrates how to handle scroll events with react-perfect-scrollbar. The onScrollY prop is used to log the vertical scroll position whenever the user scrolls.

import React from 'react';
import PerfectScrollbar from 'react-perfect-scrollbar';
import 'react-perfect-scrollbar/dist/css/styles.css';

const MyComponent = () => {
  const handleScrollY = (container) => {
    console.log('Scrolled to Y:', container.scrollTop);
  };

  return (
    <PerfectScrollbar onScrollY={handleScrollY}>
      <div style={{ height: '200px' }}>
        <p>Your content here...</p>
      </div>
    </PerfectScrollbar>
  );
};

export default MyComponent;

Other packages similar to react-perfect-scrollbar

Keywords

FAQs

Package last updated on 07 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc