Scroll
`@better-scroll/scroll-bar` powered `TxScroll` container.
Scroll
TxScroll is the current scroll container powered by @better-scroll/scroll-bar, with native-mode fallbacks for platform-specific scrolling behavior.
Behavior Notes
- BetterScroll Mode
- Supports
bouncewith a more consistent scrollbar appearance - Content/container changes auto
refresh()(configurable viarefreshOnContentChange)
- Supports
- Native Mode
- Uses native browser scrolling
directionmaps tooverflow-x/yto keep structure consistent- macOS Safari uses native scrolling directly
- Automatically falls back to native scrolling on macOS + Chromium
145+(Chromium already supports it natively) - Set
unified=trueto force BetterScroll takeover across environments
Runtime Strategy (Priority)
native=true: always use native scrolling (highest priority).unified=true: always let BetterScroll take over (consistent cross-environment behavior).- Running on macOS Safari: use native scrolling directly.
nativeAutoFallback=trueandmacOS + Chromium >= 145: auto switch to native scrolling.- Otherwise: use BetterScroll.
Basic Usage
Scroll
Demo will load when visible.
Direction and Scrollbar
Scroll (horizontal)
Demo will load when visible.
Scroll (bounce + always show scrollbar)
Demo will load when visible.
Scroll Chaining (Advanced)
By default inner scrolling does not propagate to the outer container (even at edges). Enable scrollChaining if you want scroll to bubble at the top/bottom.
⚠️ We do not recommend enabling
scrollChainingby default. In nested scrolling layouts, it can make users unsure which layer is actually scrolling. Enable it only when parent-child scroll handoff is explicitly required.
Scroll (scroll chaining, advanced)
Demo will load when visible.
Use Native Scrolling
If you do not need BetterScroll behavior, switch to native scrolling (keeps the same container structure).
Scroll (native)
Demo will load when visible.
Pull-to-Refresh and Load More
- Pull-to-refresh: enable
pullDownRefresh, listen to@pulling-down, then callfinishPullDown()when done. - Load more: enable
pullUpLoad, listen to@pulling-up, then callfinishPullUp()when done. - In
native=trueor auto-native fallback mode, events are degraded triggers;pullDownStoponly works in BetterScroll mode.
Scroll (pull down + pull up)
Demo will load when visible.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
native | boolean | false | Force native browser scrolling and skip BetterScroll initialization. |
unified | boolean | false | Force BetterScroll takeover for consistent cross-environment behavior (overrides Safari/Chromium auto-native; native=true still wins). |
nativeAutoFallback | boolean | true | Controls auto-native fallback on macOS + Chromium 145+; does not affect the macOS Safari native-first rule. |
noPadding | boolean | false | Remove the default content padding; horizontal and both-axis modes also set content width to max-content. |
scrollChaining | boolean | false | Allow parent scroll handoff at boundaries; not recommended by default, enable only when nested handoff is explicitly needed. |
direction | 'vertical' | 'horizontal' | 'both' | 'vertical' | Select the scroll axes; native mode maps this to overflow-x/y, BetterScroll maps it to scrollX, scrollY, and freeScroll. |
scrollbar | boolean | true | Enable the BetterScroll scrollbar plugin; native mode uses browser scrollbars. |
scrollbarFade | boolean | true | Pass BetterScroll scrollbar fade behavior through when scrollbar is enabled. |
scrollbarInteractive | boolean | true | Allow BetterScroll scrollbar dragging when scrollbar is enabled. |
scrollbarAlwaysVisible | boolean | false | Keep the BetterScroll wrapper in always-visible scrollbar state. |
scrollbarMinSize | number | 18 | Set the minimum BetterScroll scrollbar thumb size via --tx-scrollbar-min-size. |
probeType | 0 | 1 | 2 | 3 | 3 | BetterScroll probeType |
bounce | boolean | true | Enable BetterScroll boundary bounce and the local wheel overshoot behavior. |
click | boolean | true | Pass BetterScroll click handling through. |
wheel | boolean | true | Enable the local wheel bridge for BetterScroll mode; ctrl wheel gestures are ignored. |
refreshOnContentChange | boolean | true | Observe content mutations and call BetterScroll refresh() after changes. |
pullDownRefresh | boolean | Record<string, unknown> | false | Enable pull-down refresh; BetterScroll receives plugin options, native mode emits a threshold-based trigger. |
pullDownThreshold | number | 70 | Minimum native touch delta and BetterScroll plugin threshold for pulling-down. |
pullDownStop | number | 56 | BetterScroll pull-down stop position; native mode does not use this value. |
pullUpLoad | boolean | Record<string, unknown> | false | Enable pull-up load; BetterScroll receives plugin options, native mode emits when the bottom threshold is reached. |
pullUpThreshold | number | 0 | Native distance-to-bottom threshold and BetterScroll plugin threshold for pulling-up. |
options | Record<string, unknown> | {} | Extra BetterScroll options; wheelOvershoot is consumed locally before options are passed through. |
Events
| Event | Params | Description |
|---|---|---|
scroll | { scrollTop: number; scrollLeft: number } | Emits absolute scroll offsets from native mode or BetterScroll position updates. |
pulling-down | - | Emits once per pull-down cycle until finishPullDown() is called. |
pulling-up | - | Emits once per pull-up cycle until finishPullUp() is called. |