simplebar-react
React component for SimpleBar
Last updated 5 years ago by grsmto .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install simplebar-react 
SYNC missed versions from official npm registry.

SimpleBar


NPM version NPM downloads Build Status


SimplebarReact

Installation

- Via npm npm install simplebar-react --save

- Via Yarn yarn add simplebar-react

If you are using Gatsby, please see #345.

Usage

Check out the Demo project or our live Codesandbox example.

If you are using a module loader (like Webpack) you first need to load SimpleBar:

import SimpleBar from 'simplebar-react';
import 'simplebar/dist/simplebar.min.css';

const App = () => (
  <SimpleBar style={{ maxHeight: 300 }}>
    // your content
  </SimpleBar>
);

Don't forget to import both css and js in your project!

:warning: Warning!

SimpleBar is not intended to be used on the body element! I don't recommend wrapping your entire web page inside a custom scroll as it will often badly affect the user experience (slower scroll performance compared to the native body scroll, no native scroll behaviours like click on track, etc.). Do it at your own risk! SimpleBar is meant to improve the experience of internal web page scrolling; such as a chat box or a small scrolling area. Please read the caveats section first to be aware of the limitations!

Troubleshooting

If you are experiencing issues when setting up SimpleBar, it is most likely because your styles are clashing with SimpleBar ones. Make sure the element you are setting SimpleBar on does not override any SimpleBar css properties! We recommend to not style that element at all and use an inner element instead.

Sponsors

Thanks to BrowserStack for sponsoring open source projects and letting us test SimpleBar for free.

  1. Documentation

1. Documentation

Passing options

Find the list of available options on the core documentation.

<SimpleBar forceVisible="y" autoHide="false">
  // your content
</SimpleBar>

Extra options

scrollableNodeProps

You can pass props to the underlying scrollable div element. This is useful for example to get a ref of it, if you want to access the scroll event or apply imperative directive (like scrolling SimpleBar to the bottom, etc.).

const scrollableNodeRef = React.createRef();

<SimpleBar scrollableNodeProps={{ ref: scrollableNodeRef }}>
  // your content
</SimpleBar>

Accessing SimpleBar instance

You can pass a ref to the SimpleBar element:

const ref = useRef();

useEffect(() => {
  ref.current.recalculate();
  console.log(ref.current.el); // <- the root element you applied SimpleBar on
})

<SimpleBar ref={ref}>
  // your content
</SimpleBar>

Accessing refs

For advanced usage, you can access refs of the scrollable and content nodes by using a render prop pattern:

<SimpleBar>
  {({ scrollableNodeRef, contentNodeRef }) => {
    // Now you have access to scrollable and content nodes
    return <div></div>;
  }}
</SimpleBar>

Current Tags

  • 3.0.0-beta.12                                ...           beta (2 years ago)
  • 2.0.7-corejs2                                ...           corejs2 (5 years ago)
  • 3.2.6                                ...           latest (5 months ago)

92 Versions

  • 3.2.6                                ...           5 months ago
  • 3.2.5                                ...           6 months ago
  • 3.2.4                                ...           2 years ago
  • 3.2.3                                ...           2 years ago
  • 3.2.2                                ...           2 years ago
  • 3.2.1                                ...           2 years ago
  • 3.2.0                                ...           2 years ago
  • 3.1.1                                ...           2 years ago
  • 3.1.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 3.0.0-beta.12                                ...           2 years ago
  • 3.0.0-beta.11                                ...           2 years ago
  • 2.4.3                                ...           2 years ago
  • 2.4.2                                ...           2 years ago
  • 2.4.1                                ...           2 years ago
  • 2.4.0                                ...           2 years ago
  • 2.3.7                                ...           3 years ago
  • 2.3.6                                ...           3 years ago
  • 2.3.5                                ...           3 years ago
  • 2.3.4                                ...           3 years ago
  • 2.3.3                                ...           4 years ago
  • 2.3.2                                ...           4 years ago
  • 3.0.0-beta.10                                ...           4 years ago
  • 3.0.0-beta.9                                ...           4 years ago
  • 3.0.0-beta.8                                ...           4 years ago
  • 3.0.0-beta.7                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 3.0.0-beta.6                                ...           4 years ago
  • 3.0.0-beta.5                                ...           4 years ago
  • 3.0.0-beta.4                                ...           4 years ago
  • 3.0.0-beta.3                                ...           4 years ago
  • 3.0.0-beta.2                                ...           4 years ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0                                ...           5 years ago
  • 3.0.0-beta.1                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 3.0.0-beta.0                                ...           5 years ago
  • 2.0.10                                ...           5 years ago
  • 2.0.9                                ...           5 years ago
  • 2.0.8                                ...           5 years ago
  • 2.0.7-corejs2                                ...           5 years ago
  • 2.0.7                                ...           5 years ago
  • 2.0.6-corejs2                                ...           5 years ago
  • 2.0.6                                ...           5 years ago
  • 2.0.5                                ...           5 years ago
  • 2.0.4-corejs2                                ...           5 years ago
  • 2.0.4                                ...           5 years ago
  • 2.0.3-corejs2                                ...           5 years ago
  • 2.0.3                                ...           5 years ago
  • 2.0.2-corejs2-1                                ...           5 years ago
  • 2.0.2-corejs2                                ...           5 years ago
  • 2.0.2                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 2.0.0-alpha.0                                ...           5 years ago
  • 1.2.3-corejs2                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.3.0-alpha.1                                ...           5 years ago
  • 1.3.0-alpha.0                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 1.0.0-alpha.9                                ...           6 years ago
  • 1.0.0-alpha.8                                ...           6 years ago
  • 1.0.0-alpha.7                                ...           6 years ago
  • 1.0.0-alpha.6                                ...           6 years ago
  • 1.0.0-alpha.5                                ...           6 years ago
  • 1.0.0-alpha.4                                ...           6 years ago
  • 1.0.0-alpha.3                                ...           6 years ago
  • 1.0.0-alpha.2                                ...           6 years ago
  • 1.0.0-alpha.1                                ...           6 years ago
  • 1.0.0-alpha.0                                ...           6 years ago
  • 0.1.6                                ...           6 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.1.0-beta.5                                ...           6 years ago
  • 0.1.0-beta.4                                ...           6 years ago
  • 0.1.0-beta.3                                ...           6 years ago
  • 0.1.0-beta.2                                ...           6 years ago
  • 0.1.0-beta.1                                ...           6 years ago
  • 0.0.1-beta.4                                ...           6 years ago
  • 0.0.1-beta.3                                ...           6 years ago
  • 0.0.1-beta.2                                ...           6 years ago
  • 0.0.1-beta.1                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.1-beta.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE