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

stylable-scrollbar

v1.0.9

Published

Easy to use, custom JS scrollbar.

Downloads

24

Readme

stylable-scrollbar

Easy to use, super lightweight (only 6KB~ for UMD Module) and fully stylable, customisable JS scrollbar.

Once you define your scrollbar and scrollbar scrollable containers with the same ID, as can be seen in the examples, you can easily place them anywhere on the page and style them to your liking.

You can even add more HTML inside the defined scrollbars and style that too. e.g. icons, backgrounds, extra buttons etc.

INSTALLATION

npm i stylable-scrollbar

USAGE

Import

ESM

import initStylableScrollbars from 'stylable-scrollbar'
initStylableScrollbars()

CJS

const initStylableScrollbars = require('stylable-scrollbar')
initStylableScrollbars()

Vanilla JS

<script src="https://unpkg.com/[email protected]/dist/umd/index.umd.js"></script>
<script>
    window.initStylableScrollbars()
</script>

Example

Check out a minimal example at https://jasondonnellya.github.io/stylable-scrollbar/ and below is a basic usage example containing two separate scrollbars.

<!-- The stylable-scrollbar-scrollable attribute must have a value which acts as an ID. -->
<div stylable-scrollbar-scrollable="example"></div>

<!-- The stylable-scrollbar attribute must have a matching ID to it's scrollable container as seen above. -->
<div stylable-scrollbar="example" direction="horizontal">
    <div stylable-scrollbar-handle></div>
</div>



<div stylable-scrollbar-scrollable="2"></div>

<!-- If a direction is not applied to the scrollbar, vertical is the default. -->
<div stylable-scrollbar="2" direction="vertical">
    <div stylable-scrollbar-handle></div>
</div>

DOCUMENTATION

Attributes

stylable-scrollbar-scrollable

(*) Requires a value that acts as an 'id' matching the scrollable container.

stylable-scrollbar

(*) Requires a value that acts as an 'id' matching the scrollable container.

stylable-scrollbar-handle

The handle of the scrollbar.

direction

The direction which the scollbar scrolls. ("horizontal", "vertical") defaults to "vertical".

scrollspeed

Scrollspeed defines what speed the container scrolls at when using the mousewheel. (number) defaults to 1.

responsive

The responsive attribute dictates whether a scrollbar should hide when it is not possible to scroll the container. (true, false) defaults to true

Settings

It is possible to pass an object that contains settings for stylable-scrollbar as shown.

initStylableScrollbars({ keepContainerScrollbars: true })

keepContainerScrollbars: Boolean

This will ignore the CSS that is generated to remove scrollbars from any element with selector [stylable-scrollbar-scrollable] so you can keep the default scrollbars within the containers.

Custom CSS.

It is easy to target all the built in HTML of stylable-scrollbar using the attribute selector, see below example.

:root {
  --width: 300px;
  --height: 20px;
}

[stylable-scrollbar-scrollable] {
  width: var(--width);
  height: var(--width);
  padding: 10px;
  background: rgb(240, 240, 240);
}

[stylable-scrollbar] {
  width: var(--width);
  height: var(--height);
  background: lightgray;
  border: solid transparent 0px;
  border-radius: 20px;
  /* Add display none here to hide scrollbars before JS has loaded. */
  display: none;
}
[stylable-scrollbar-handle] {
  width: 40px;
  height: 20px;
  background: darkgrey;
  border: solid transparent 0px;
  border-radius: 20px;
  box-shadow: 0px 0px 5px 1px black;
}

[stylable-scrollbar] [direction="vertical"] {
  width: var(--height);
  height: var(--width);

  [stylable-scrollbar-handle] {
    width: 20px;
    height: 40px;
  }
}

SUPPORT

If you notice any constraints or bugs with this scrollbar, or you would just like to suggest features, don't hesitate to open an issue on the GitHub repository. Thanks!