{"name":"overlayscrollbars-react","version":"0.5.2","description":"OverlayScrollbars for React.","author":{"name":"Rene Haas | KingSora"},"license":"MIT","homepage":"https://kingsora.github.io/OverlayScrollbars","bugs":{"url":"https://github.com/KingSora/OverlayScrollbars/issues"},"repository":{"type":"git","url":"git+https://github.com/KingSora/OverlayScrollbars.git","directory":"packages/overlayscrollbars-react"},"keywords":["overlayscrollbars","react","component","hook","hooks","styleable","custom","scrollbar","scrollbars","scroll"],"main":"overlayscrollbars-react.umd.js","module":"overlayscrollbars-react.es.js","types":"types/overlayscrollbars-react.d.ts","exports":{".":{"require":"./overlayscrollbars-react.cjs.js","import":"./overlayscrollbars-react.es.js","types":"./types/overlayscrollbars-react.d.ts"}},"peerDependencies":{"react":">=16.8.0","overlayscrollbars":"^2.0.0"},"sideEffects":false,"gitHead":"7621541a6cfd24baa908ecc34280d141c9c12a12","_id":"overlayscrollbars-react@0.5.2","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-y3xIPY3to7hneF30MQ/tK9nI6UOcflgenAYktgyfi0GuwnsYEuAqgLfs2qDGiNhFA30Xcz3gaMxvqD7+hTvFRA==","shasum":"b8a6294279a1d0984392586b56a03df78d6c1e34","tarball":"http://registry-npm.ywwl.com/overlayscrollbars-react/download/overlayscrollbars-react-0.5.2.tgz","fileCount":12,"unpackedSize":52817,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAcTeSSj+aNK0YCUvqnKW1ATp7+3r1H28H5dDPmJk9x5AiEAlP87vsuAI9mcCrST5YJH85dwd1h12NayQnRluDWshg8="}],"size":9893,"noattachment":false,"key":"/overlayscrollbars-react/-/overlayscrollbars-react-0.5.2.tgz"},"_npmUser":{"name":"kingsora","email":"king-sora@hotmail.de"},"directories":{},"maintainers":[{"name":"kingsora","email":"king-sora@hotmail.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/overlayscrollbars-react_0.5.2_1692997519222_0.8850223315713766"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <a href=\"https://kingsora.github.io/OverlayScrollbars\"><img src=\"https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/logo/logo.png\" width=\"160\" height=\"160\" alt=\"OverlayScrollbars\"></a>\n  <a href=\"https://reactjs.org\"><img src=\"https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-react/logo.svg\" width=\"160\" height=\"160\" alt=\"React\"></a>\n</div>\n<br />\n<div align=\"center\">\n\n  [![OverlayScrollbars](https://img.shields.io/badge/OverlayScrollbars-%5E2.0.0-338EFF?style=flat-square)](https://github.com/KingSora/OverlayScrollbars)\n  [![React](https://img.shields.io/badge/React-%3E=16.8.0-61DAFB?style=flat-square&logo=React)](https://github.com/facebook/react/)\n  [![Downloads](https://img.shields.io/npm/dt/overlayscrollbars-react.svg?style=flat-square)](https://www.npmjs.com/package/overlayscrollbars-react)\n  [![Version](https://img.shields.io/npm/v/overlayscrollbars-react.svg?style=flat-square)](https://www.npmjs.com/package/overlayscrollbars-react)\n  [![License](https://img.shields.io/github/license/kingsora/overlayscrollbars.svg?style=flat-square)](#)\n\n</div>\n<h3 align=\"center\">\n  <a href=\"https://kingsora.github.io/OverlayScrollbars\">Website</a>\n  &nbsp;&nbsp;&bull;&nbsp;&nbsp;\n  <a href=\"https://kingsora.github.io/OverlayScrollbars/examples\">Examples</a>\n</h3>\n\n# OverlayScrollbars for React\n\nThis is the official OverlayScrollbars React wrapper.\n\n## Installation\n\n```sh\nnpm install overlayscrollbars-react\n```\n\n## Peer Dependencies\n\nOverlayScrollbars for React has the following **peer dependencies**:\n\n- The vanilla JavaScript library: [overlayscrollbars](https://www.npmjs.com/package/overlayscrollbars)\n\n```\nnpm install overlayscrollbars\n```\n\n- The React framework: [react](https://www.npmjs.com/package/react)\n\n```\nnpm install react\n```\n\n## Usage\n\nThe first step is to import the CSS file into your app:\n```ts\nimport 'overlayscrollbars/overlayscrollbars.css';\n```\n\n> __Note__: If the path `'overlayscrollbars/overlayscrollbars.css'` is not working use `'overlayscrollbars/styles/overlayscrollbars.css'` as the import path for the CSS file.\n\n## Component\n\nThe main entry point is the `OverlayScrollbarsComponent` which can be used in your application as a component:\n\n```jsx\nimport { OverlayScrollbarsComponent } from \"overlayscrollbars-react\";\n\n// ...\n\n<OverlayScrollbarsComponent defer>\n  example content\n</OverlayScrollbarsComponent>\n```\n\n### Properties\n\nThe component accepts all properties of regular elements such as `div` and `span`.  \nAdditionally it has custom optional properties:\n\n- `element`: accepts a `string` which represents the tag of the root element.\n- `options`: accepts an `object` which represents the OverlayScrollbars options.\n- `events`: accepts an `object` which represents the OverlayScrollbars events.\n- `defer`: accepts an `boolean` or `object`. Defers the initialization to a point in time when the browser is idle.\n\n> __Note__: None of the properties has to be memoized.\n\n> __Note__: Its **highly recommended** to use the `defer` option whenever possible to defer the initialization to a browser's idle period.\n\n```jsx\n// example usage\n<OverlayScrollbarsComponent\n  element=\"span\"\n  options={{ scrollbars: { autoHide: 'scroll' } }}\n  events={{ scroll: () => { /* ... */ } }}\n  defer\n/>\n```\n\n### Ref\n\nThe `ref` of the `OverlayScrollbarsComponent` will give you an object with which you can access the OverlayScrollbars `instance` and the root `element` of the component.  \nThe ref object has two properties:\n\n- `osInstance`: a function which returns the OverlayScrollbars instance.\n- `getElement`: a function which returns the root element.\n\n## Hook\n\nIn case the `OverlayScrollbarsComponent` is not enough, you can also use the `useOverlayScrollbars` hook:\n\n```jsx\nimport { useOverlayScrollbars } from \"overlayscrollbars-react\";\n\n// example usage\nconst Component = () => {\n  const ref = useRef();\n  const [initialize, instance] = useOverlayScrollbars({ options, events, defer });\n  \n  useEffect(() => {\n    initialize(ref.current);\n  }, [initialize]);\n  \n  return <div ref={ref} />\n}\n```\n\nThe hook is for advanced usage and lets you control the whole initialization process. This is useful if you want to integrate it with other plugins such as `react-window` or `react-virtualized`.\n\nThe hook will destroy the instance automatically if the component unmounts.\n\n### Parameters\n\nParameters are optional and similar to the `OverlayScrollbarsComponent`.\nIts an `object` with optional properties:\n\n- `options`: accepts an `object` which represents the OverlayScrollbars options.\n- `events`: accepts an `object` which represents the OverlayScrollbars events.\n- `defer`: accepts an `boolean` or `object`. Defers the initialization to a point in time when the browser is idle.\n\n### Return\n\nThe `useOverlayScrollbars` hook returns a `tuple` with two values:\n\n- The first value is the `initialization` function, it takes one argument which is the `InitializationTarget`.\n- The second value is a function which returns the current OverlayScrollbars instance or `null` if not initialized.\n\n> __Note__: The identity of both functions is stable and won't change, thus they can safely be used in any dependency array.\n\n## License\n\nMIT\n","publish_time":1692997519481,"_cnpm_publish_time":1692997519481,"dist-tags":{"latest":"0.5.7"}}