react-scrollbars-custom is a React component that provides highly customizable scrollbars while preserving native browser scrolling behavior. Unlike many alternatives, it does not emulate scrolling but rather styles the native scrollbars, ensuring optimal performance (60 FPS using requestAnimationFrame) and a consistent experience across different browsers and platforms. Key features include cross-browser compatibility, full customizability for look and feel, scrollbar nesting, momentum scrolling for iOS, RTL support, and proper handling of page zoom. The current stable version is 4.1.1, released in August 2022, indicating a maintenance phase following active development. It differentiates itself by its performance-focused approach and extensive customization options, including allowing users to define their own renderer components.
npm install react-scrollbars-customVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `Scrollbar` into a React component, setting its dimensions and populating it with content to enable scrolling. It also shows how to opt out of default styling.
Ensure your project uses React `>=16.0.0`. If you had custom `prop-types` validators for `react-scrollbars-custom` props, these may no longer be necessary or need to be adapted for TypeScript types.
Always provide `width` and `height` to the `Scrollbar` component, e.g., `<Scrollbar style={{ width: 250, height: 250 }}>` or ensure they are applied via CSS.Include `@babel/polyfill` or similar polyfills in your project if targeting IE10 or older browsers.
Refer to your bundler's documentation (e.g., Webpack `resolve.mainFields` or Babel `browserslist` configuration) to ensure the correct module version is used and transpiled for your target environments.
When using `noDefaultStyles`, provide your own CSS for visual customization. Be aware that certain layout-critical styles are always applied internally.
Ensure the `<Scrollbar>` component has defined `width` and `height` styles (e.g., `style={{ width: 300, height: 200 }}`) or via CSS. Also, verify that the content inside the `Scrollbar` is larger than these dimensions to trigger scrolling.Ensure `react` is installed as a dependency and meets the `>=16.0.0` peer dependency requirement. Check your bundler configuration to ensure `react` is resolved correctly. For `react-scrollbars-custom v4.1.0` and above, the `prop-types` dependency was removed, which could also affect older setups.
Upgrade to `react-scrollbars-custom@4.1.1` or higher, which includes a fix to replace `global` with proper browser environment detection.
Verify that `noDefaultStyles` is passed to the `<Scrollbar>` component. If providing custom renderers (e.g., for `renderThumbVertical`), ensure that essential styles are explicitly passed to your custom renderer components as described in the documentation, as some styles are crucial for functional correctness. Use higher CSS specificity for your custom styles if needed.