Scroll Area

A scrollable region with a slim scrollbar that follows the theme and works with the keyboard. It uses the browser's own scrolling, so touch, wheel and trackpad behave as usual.

General

Set a height and the content scrolls when it is taller. Add an aria-label so screen readers name the region.

Horizontal

Use orientation to scroll sideways, or both for both directions. A sideways scrollbar gets space below the content, scrollbar='hover' shows it only while the pointer is over the area, and the mouse wheel scrolls it sideways.

Hover scrollbar

Use scrollbar='hover' to show the scrollbar only while the pointer or the focus is inside.

APIs

ScrollArea.Props

AttributeDescriptionTypeAccepted valuesDefault
orientationdirection of the scroll'vertical' / 'horizontal' / 'both'-'vertical'
scrollbar'hover' hides the scrollbar until the pointer or the focus is inside'always' / 'hover'-'always'
heightheight of the region; a number is a multiple of the theme unitstring / number'160px', ...auto
classNameclass of the root elementstring--
...native props, passed to the scrolling elementHTMLAttributes'id', 'aria-label', ...-

Ref

The ref points at the scrolling element, so you can read or set scrollTop and scrollLeft.

Accessibility

The region takes focus with Tab, so the arrow keys, Page Up, Page Down, Home and End scroll it without a mouse. Pass aria-label or aria-labelledby to name it.

Edit this page on GitHub