This documentation is under construction. Pages can be missing or change at any time. Follow it on GitHub.

Skip to content

Scroll Area

A native scroll container with custom scrollbars.

Examples#

Both scrollbars#

Use ScrollAreaCorner to prevent the scrollbars from intersecting.

Gradient scroll fade#

Use the viewport overflow CSS variables to drive a CSS mask, which gradually increases the fade as the user scrolls away from the edges.

The server render has no overflow variables yet, so give a fallback to the end-side var() call: the mask shows before the controller connects.

When the fade is applied to ScrollAreaViewport itself, the variables can be used directly. However, inheritance to children is disabled, so they must explicitly opt-in using the inherit keyword.

Combining with Tabs#

Put the TabsList in a ScrollAreaViewport when the tab list needs the viewport overflow values for a mask fade.

API reference#

Import the components of the family:

use function Phem\Ui\{ScrollArea, ScrollAreaViewport, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaCorner};

ScrollArea#

Custom scrollbars over a native scroll container: Base UI ScrollArea.Root, on the phem-scroll-area controller. The scrollbars show while the pointer is over the area, or while the user scrolls.

PropTypeDefault
overflowEdgeThresholdint|array0
children?Htmlnull
...restmixed—

ScrollAreaViewport#

The element that scrolls.

PropTypeDefault
children?Htmlnull
...restmixed—

ScrollAreaContent#

The content of the scroll area, in the ScrollAreaViewport.

PropTypeDefault
children?Htmlnull
...restmixed—

ScrollAreaScrollbar#

A scrollbar on one axis. It gets hidden when its axis has no overflow.

PropTypeDefault
orientation'horizontal' | 'vertical'Orientation::Vertical
children?Htmlnull
...restmixed—

ScrollAreaThumb#

The thumb of a ScrollAreaScrollbar: its size and its position show the part of the content in view.

PropTypeDefault
...restmixed—

ScrollAreaCorner#

The square between the two scrollbars.

PropTypeDefault
...restmixed—

The source of the examples: examples/ui/ScrollArea.phem.

Phem
Esc
↑↓ to navigate↵ to openEsc to close