ScrollArea
Area with custom scrollbars
Import
Source
Docs
Package
Usage
ScrollArea component is based on Radix UI scroll area component. It is adapted to work well with light and dark color schemes and supports the following props:
- typedefines scrollbars behavior:- hover– scrollbars are visible on hover
- scroll– scrollbars are visible on scroll
- auto– similar to- overflow: auto– scrollbars are always visible when the content is overflowing
- always– same as- autobut scrollbars are always visible regardless of whether the content is overflowing
- never– scrollbars are always hidden
 
- offsetScrollbars– offset scrollbars with padding
- scrollbarSize– scrollbar size, controls scrollbar and thumb width/height
- scrollHideDelay– delay in ms to hide scrollbars, applicable only when type is- hoveror- scroll
Horizontal scrollbars
Subscribe to scroll position changes
Provider onScrollPositionChange function to subscribe to scroll position changes,
it will be called each time user scrolls with x and y coordinates:
Scroll position: 
{ x: 0, y: 0 }Scroll to position
To programmatically scroll to any position,
get viewport element ref with viewportRef prop and call scrollTo method:
Usage with other components
ScrollArea integrates seamlessly with all Mantine components that can require scrollbars. For example, it can be used with Navbar.Section component:
Styles API
ScrollArea.Autosize
ScrollArea.Autosize component allows to create scrollable containers when given maxHeight is reached:
ScrollArea component props
| Name | Type | Description | 
|---|---|---|
| dir | "ltr" | "rtl" | Reading direction of the scroll area | 
| offsetScrollbars | boolean | Should scrollbars be offset with padding | 
| onScrollPositionChange | (position: { x: number; y: number; }) => void | Subscribe to scroll position changes | 
| scrollHideDelay | number | Scroll hide delay in ms, for scroll and hover types only | 
| scrollbarSize | string | number | Scrollbar size | 
| type | "auto" | "scroll" | "always" | "never" | "hover" | Scrollbars type | 
| viewportProps | Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & { ref?: Ref<HTMLDivElement>; } | Props added to the viewport element | 
| viewportRef | ForwardedRef<HTMLDivElement> | Get viewport ref | 
ScrollArea component Styles API
| Name | Static selector | Description | 
|---|---|---|
| root | .asuikit-ScrollArea-root | Root element | 
| corner | .asuikit-ScrollArea-corner | Corner between horizontal and vertical scrollbars | 
| viewport | .asuikit-ScrollArea-viewport | Children wrapper | 
| scrollbar | .asuikit-ScrollArea-scrollbar | Scrollbar | 
| thumb | .asuikit-ScrollArea-thumb | Scrollbar thumb |