Homelogologo
Sponsor

ScrollArea

A component that provides custom scrollbars for overflowing content.

Usage

A compound component that provides a way to scroll content with custom-styled scrollbars.

import { ScrollArea } from "@elemnts-ui/react"; <ScrollArea.Root> <ScrollArea.Viewport> <ScrollArea.Content>{/* Your content here */}</ScrollArea.Content> </ScrollArea.Viewport> <ScrollArea.Scrollbar orientation="vertical"> <ScrollArea.Thumb /> </ScrollArea.Scrollbar> <ScrollArea.Scrollbar orientation="horizontal"> <ScrollArea.Thumb /> </ScrollArea.Scrollbar> <ScrollArea.Corner /> </ScrollArea.Root>;

Variants

Control when scrollbars are shown using the variant prop: hover (default) displays them on hover, while always keeps them visible at all times.

Sizes

Use the size prop to adjust the scroll area. It controls scrollbar thickness and content padding.

Horizontal Scrolling

Horizontal scrolling is automatically enabled when the content exceeds the container's width.

RTL Support

The scroll area component fully supports Right-to-Left (RTL) languages like Arabic and Hebrew.

API Reference

ScrollArea

The root component for the scroll area.

PropTypeDefault
idsPartial<{ root: string; viewport: string; content: string; scrollbar: string; thumb: string }>-
asChildbooleanfalse

ScrollAreaRootProvider

Provides a scroll area context created with useScrollArea.

PropTypeDefault
valueUseScrollAreaReturnrequired
asChildbooleanfalse

ScrollAreaViewport

The scrollable viewport.

PropTypeDefault
asChildbooleanfalse

ScrollAreaContent

The content container within the viewport.

PropTypeDefault
asChildbooleanfalse

ScrollAreaScrollbar

The scrollbar container.

PropTypeDefault
orientation"horizontal" | "vertical"-
asChildbooleanfalse

ScrollAreaThumb

The draggable thumb within a scrollbar.

PropTypeDefault
asChildbooleanfalse

ScrollAreaCorner

The corner element displayed where horizontal and vertical scrollbars meet.

PropTypeDefault
asChildbooleanfalse

ScrollAreaContext

Accesses the scroll area state and methods.

PropertyTypeDescription
isAtTopbooleanWhether the scroll area is at the top edge.
isAtBottombooleanWhether the scroll area is at the bottom edge.
isAtLeftbooleanWhether the scroll area is at the left edge.
isAtRightbooleanWhether the scroll area is at the right edge.
hasOverflowXbooleanWhether the content overflows horizontally.
hasOverflowYbooleanWhether the content overflows vertically.
getScrollProgress() => PointReturns the scroll progress for each axis as values between 0 and 1.
scrollToEdge(details: ScrollToEdgeDetails) => voidScrolls to an edge of the scroll area.
scrollTo(details: ScrollToDetails) => voidScrolls to specific coordinates.
getScrollbarState(props: ScrollbarProps) => ScrollbarStateReturns a scrollbar's state.