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

react-cool-scrollbar

v1.4.2

Published

Custom scroollbar for react applications. It's easy to use with scrolling experience.

Downloads

66

Readme

npm NPM License ReactJS

react-cool-scrollbar

It's a simple react library for a customized browser independent scrollbar for your web page

Installation

npm

npm install react-cool-scrollbar

or yarn

yarn add react-cool-scrollbar

Demo

Here you can find a demo

Features

  • Scrollbar customization (external component can be provided as scroll thumb or track)
  • Customizable scrollbar width

How to use

import component and styles

Import ReactCoolScrollbar component and styles

import { ReactCoolScrollbar } from "react-cool-scrollbar"; //scroller component
import "react-cool-scrollbar/dist/style.css"; //style files

Using the component

You can use the component like below example-

function App() {
  return (
    <div className="app">
      {/** .app {display: flex;} */}

      <ReactCoolScrollbar>
        {/** your scrollable content here */}
      </ReactCoolScrollbar>
    </div>
  );
}

export default App;

You must import the style file to make the scrollbar work.
Make sure the parent of ReactCoolScrollbar component must be the scroll host of the scrollable content.
Make the style property of the parent as display:flex. This will work in most cases.

Props

  • ref: A ref object can be passed to the component which will point to the scroller view of the page which is a div element. This can be used to programatically scroll the view or anything needed as per the the requirements.

  • scrollBarVisibility: This prop can receive 3 types of conditions to make the scrollbar visible on the UI.

    • always: Scrollbar will be always visible.
    • onhover: Scrollbar will be visible on hover the scroll container.
    • onscroll: Scrollbar will be visible on scrolling the page.
  • scrollerWidth : Receives a number as input to set the width of the scrollbar.

  • className : Can be used to style the custom scrollbar. The className will be applied on the container of scrollTrack and scrollThumb

  • customScrollTrack : You can customize the scroll track by passing a component or a function that will return a component.

    • Example:
      <ReactCoolScrollbar
        customScrollTrack={<div className="custom-scroll"></div>}
      >
        {/** your scrollable content here */}
      </ReactCoolScrollbar>
      or
      <ReactCoolScrollbar
        customScrollTrack={(props) => (
          <div className="custom-scroll" {...props}></div>
        )}
      >
        {/** your scrollable content here */}
      </ReactCoolScrollbar>
      The passed component or function will receive the following props
     handleMouseDown: (e: MouseEvent<HTMLDivElement>) => void;
     handleMouseUp: (e: MouseEvent<HTMLDivElement>) => void;

    If you use a separate component or function then you have to pass every received prop to your component.

  • customScrollThumb : Same as customScrollTrack prop but it will customize the scroll thumb component. This component will receive prop

    •     handleMouseDown: (e: MouseEvent<HTMLDivElement>) => void;
      you have to be careful here that these props are passing down to your custom component properly

License

MIT