Skip to main content

Scroll Area

View as Markdown

A native scroll container with custom scrollbars.

<primitives:scrollArea.root>
    <primitives:scrollArea.viewport>
        <primitives:scrollArea.content />
    </primitives:scrollArea.viewport>
    <primitives:scrollArea.scrollbar>
        <primitives:scrollArea.thumb />
    </primitives:scrollArea.scrollbar>
</primitives:scrollArea.root>
typo3 ui:add scrollArea

Read more about installing Components and Primitives.

Add a horizontal scrollbar for wide content, like a row of product cards.

Add one scrollbar per orientation for content that is wider and taller than the area, like a large table.

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

Provides the scroll area container and shared state. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-scroll-area-root<uid>
data-overflow-xPresent when the content overflows the x-axis
data-overflow-yPresent when the content overflows the y-axis

Provides the native scrollable viewport. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-scroll-area-viewport<uid>
data-at-topPresent when scrolled to the top edge
data-at-bottomPresent when scrolled to the bottom edge
data-at-leftPresent when scrolled to the left edge
data-at-rightPresent when scrolled to the right edge
data-overflow-xPresent when the content overflows the x-axis
data-overflow-yPresent when the content overflows the y-axis

Wraps the scrollable content to measure its size. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-scroll-area-content<uid>
data-overflow-xPresent when the content overflows the x-axis
data-overflow-yPresent when the content overflows the y-axis

Displays a custom scrollbar track. Renders a <div> element.

NameDescriptionRequiredDefault
orientationEnum\Orientation
The orientation of the scrollbar.
No
Vertical
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-scroll-area-scrollbar<uid>
data-orientationThe orientation of the scrollbar
data-scrollingPresent when scrolling
data-hoverPresent when hovered
data-draggingPresent when in the dragging state
data-overflow-xPresent when the content overflows the x-axis
data-overflow-yPresent when the content overflows the y-axis

Displays the draggable scrollbar thumb. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-scroll-area-thumb<uid>
data-orientationThe orientation of the thumb
data-hoverPresent when hovered
data-draggingPresent when in the dragging state
NameTypeDescription
isAtTopbooleanWhether the scroll area is at the top
isAtBottombooleanWhether the scroll area is at the bottom
isAtLeftbooleanWhether the scroll area is at the left
isAtRightbooleanWhether the scroll area is at the right
hasOverflowXbooleanWhether the scroll area has horizontal overflow
hasOverflowYbooleanWhether the scroll area has vertical overflow
getScrollProgress() => PointGet the scroll progress as values between 0 and 1
scrollToEdge(details: ScrollToEdgeDetails) => voidScroll to the edge of the scroll area
scrollTo(details: ScrollToDetails) => voidScroll to specific coordinates
getScrollbarState(props: ScrollbarProps) => ScrollbarStateReturns the state of the scrollbar
getCornerState() => CornerStateReturns the state of the corner