onScroll: (Function) Event handler- Signature:
onScroll(event)
- Signature:
onScrollFrame: (Function) Runs inside the animation frame.- Signature:
onScrollFrame(values) values: (Object) Values about the current positionvalues.top: (Number) scrollTop progress, from 0 to 1values.left: (Number) scrollLeft progress, from 0 to 1values.clientWidth: (Number) Width of the viewvalues.clientHeight: (Number) Height of the viewvalues.scrollWidth: (Number) Native scrollWidthvalues.scrollHeight: (Number) Native scrollHeightvalues.scrollLeft: (Number) Native scrollLeftvalues.scrollTop: (Number) Native scrollTop
- Signature:
onScrollStart: (Function) Called when scrolling startsonScrollStop: (Function) Called when scrolling stopsonUpdate: (Function) Called whenever the component is updated. Runs inside the animation frame- Signature:
onUpdate(values)
- Signature:
renderView: (Function) The element your content will be rendered inrenderTrackHorizontal: (Function) Horizontal track elementrenderTrackVertical: (Function) Vertical track elementrenderThumbHorizontal: (Function) Horizontal thumb elementrenderThumbVertical: (Function) Vertical thumb elementhideTracksWhenNotNeeded: (Boolean) Hide tracks (visibility: hidden) when content does not overflow container. (default: false)thumbSize: (Number) Set a fixed size for thumbs in px.thumbMinSize: (Number) Minimal thumb size in px. (default: 30)autoHide: (Boolean) Enable auto-hide mode (default:false)- When
truetracks will hide automatically and are only visible while scrolling.
- When
autoHideTimeout: (Number) Hide delay in ms. (default: 1000) ✨ New in v5.0autoHideDuration: (Number) Duration for hide animation in ms. (default: 200)autoHeight: (Boolean) Enable auto-height mode. (default: false)- When
truecontainer grows with content
- When
autoHeightMin: (Number) Set a minimum height for auto-height mode (default: 0)autoHeightMax: (Number) Set a maximum height for auto-height mode (default: 200)universal: (Boolean) Enable universal rendering (default:false)style: (CSSProperties) Custom styles for the container ✨ Improved TypeScript support in v5.0className: (String) CSS class name for the container
This library is now written in TypeScript and exports proper types:
import { Scrollbars, ScrollbarsRef, ScrollValues } from 'react-custom-scrollbars'
// All props are properly typed
const scrollbars = useRef<ScrollbarsRef>(null)The component exposes methods through a ref:
scrollTop(top = 0): scroll to the top valuescrollLeft(left = 0): scroll to the left valuescrollToTop(): scroll to topscrollToBottom(): scroll to bottomscrollToLeft(): scroll to leftscrollToRight(): scroll to rightgetScrollLeft(): get scrollLeft valuegetScrollTop(): get scrollTop valuegetScrollWidth(): get scrollWidth valuegetScrollHeight(): get scrollHeight valuegetClientWidth(): get view client widthgetClientHeight(): get view client heightgetValues(): get an object with values about the current position.
- React: Minimum React version is now 18.0.0
- Node.js: Minimum Node.js version is now 20.0.0
- TypeScript: The library is now written in TypeScript
- ES Modules: Only ES module exports are supported (no CommonJS)
- Hooks: Component is now implemented with React hooks instead of class components
All original APIs are maintained for backward compatibility.