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-baron

v3.0.0

Published

React component for baron scrollbar library

Downloads

231

Readme

React-baron

  1. Native scroll mechanic
  2. No extra css (css-modules) by default
  3. Flexible configuration:
    1. vertical, horizontal and bidirectional scroll;
    2. nested scrollers;
    3. flexbox;
    4. different width/height modes.
  4. Full css customization: no inline styles, change css and/or classNames as you want
  5. Auto show/hide/resize/update
  6. Isomorphic (server side rendering support out of the box)
  7. Wide range of browsers support (ie10+, Safari5+, Android4+, Opera11+)
  8. 100% code coverage
  9. 5.9 kB (gzip)

Baron demo

How to use

npm i react-baron --save

Default way

import Baron from 'react-baron'
// or Baron = require('react-baron')

...
<Baron>
  ...Scrollable content here...
</Baron>

Note: you need configured loaders: babel-loader and css-modules in your application.

If you have any problems this way, follow manual way:

Manual way

  1. Import from custom path:
import Baron from 'react-baron/dist/es5'
// or Baron = require('react-baron/dist/es5')

...
<Baron>
  ...Scrollable content here...
</Baron>
  1. Add css from react-baron/src/styles.css (via postcss-global-import or something else):
.clipper {
  position: relative;
  overflow: hidden;
  height: 100%;
}
.scroller {
  overflow: auto;
  height: 100%;
}
.scroller::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.track {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  width: 0;
}
.track._h {
  top: auto;
  width: auto;
  height: 0;
  left: 2px;
}
.baron > .track {
  display: block;
}
.bar {
  position: absolute;
  right: 0;
  width: 6px;
  border-radius: 3px;
  background: #ccc;
}
.bar._h {
  bottom: 0;
  right: auto;
  width: auto;
  height: 6px;
}

Note: you can change any classNames: just pass them as props to Baron (see below).

API

All props are optional. You can see default props next to =:

props.params = {defaultParams} // Object that will be passed to baron as `params` (see baron API https://github.com/Diokuz/baron)
props.clipperCls = "clipper"   // className for clipper/root dom node
props.scrollerCls = "scroller" // className for scroller dom node
props.trackCls = "track"       // className for track dom node
props.barCls = "bar"           // className for bar dom node

// Note, that defaultParams is not actually a default prop, it is a defaults for `props.params` object.
defaultParams = {
  barOnCls: 'baron',
  direction: 'v'
}

Plus, from within your component you have the following methods:

// Define ref
<Baron ref={(r) => this.baronRef = r}>

// Then you have some ReactBaron methods

// Scroll as far as possible
this.baronRef.scrollToLast()

// Get DOM-node scroller
this.baronRef.getScroller();

// Get DOM-node clipper
this.baronRef.getClipper();

// onScroll handler
onScroll: PropTypes.func;

Browsers support

| | | | | | | |:---:|:---:|:---:|:---:|:---:|:---:| | 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.5+ ✔ | 5.1+ ✔ | 4+ ✔ |

Alternatives

react-custom-scrollbars