Skip to contents

Scroll Area

A native scroll container with custom scrollbars.

View as Markdown

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Both scrollbars

Use <ScrollArea.Corner> to prevent the scrollbars from intersecting.

Gradient scroll fade

Use the viewport overflow CSS variables to fade the scroll edges, which gradually increases in strength as the user scrolls away from the edges.

The CSS variables do not inherit by default to improve rendering performance in complex scroll areas with deep subtrees. To use them in child elements (or pseudo-elements on <ScrollArea.Viewport>), you must manually set each variable to inherit.

scroll-area.module.css

For SSR, a fallback can be used as part of the var() function to provide a default height.

SSR fallback

API reference

Root

Groups all parts of the scroll area. Renders a <div> element.

overflowEdgeThresholdUnion0
Description

The threshold in pixels that must be passed before the overflow edge attributes are applied. Accepts a single number for all edges or an object to configure them individually.

Type
Default
0
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

AttributeDescription
data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

--scroll-area-corner-height

The scroll area’s corner height.

--scroll-area-corner-width

The scroll area’s corner width.

CSS VariableDescription
--scroll-area-corner-height

The scroll area’s corner height.

--scroll-area-corner-width

The scroll area’s corner width.

ScrollArea.Root.PropsHide

Re-Export of Root props as ScrollAreaRootProps

ScrollArea.Root.StateHide

Viewport

The actual scrollable container of the scroll area. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

AttributeDescription
data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

--scroll-area-overflow-x-end

The distance from the horizontal end edge in pixels.

--scroll-area-overflow-x-start

The distance from the horizontal start edge in pixels.

--scroll-area-overflow-y-end

The distance from the vertical end edge in pixels.

--scroll-area-overflow-y-start

The distance from the vertical start edge in pixels.

CSS VariableDescription
--scroll-area-overflow-x-end

The distance from the horizontal end edge in pixels.

--scroll-area-overflow-x-start

The distance from the horizontal start edge in pixels.

--scroll-area-overflow-y-end

The distance from the vertical end edge in pixels.

--scroll-area-overflow-y-start

The distance from the vertical start edge in pixels.

ScrollArea.Viewport.PropsHide

Re-Export of Viewport props as ScrollAreaViewportProps

ScrollArea.Viewport.StateHide

Content

A container for the content of the scroll area. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

ScrollArea.Content.PropsHide

Re-Export of Content props as ScrollAreaContentProps

ScrollArea.Content.StateHide

Scrollbar

A vertical or horizontal scrollbar for the scroll area. Renders a <div> element.

orientation'vertical' | 'horizontal''vertical'
Description

Whether the scrollbar controls vertical or horizontal scroll.

Type
Default
'vertical'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
keepMountedbooleanfalse
Description

Whether to keep the HTML element in the DOM when the viewport isn’t scrollable.

Type
Default
false
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the scrollbar.

data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-hovering

Present when the pointer is over the scroll area.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

AttributeDescription
data-orientation

Indicates the orientation of the scrollbar.

data-has-overflow-x

Present when the scroll area content is wider than the viewport.

data-has-overflow-y

Present when the scroll area content is taller than the viewport.

data-hovering

Present when the pointer is over the scroll area.

data-overflow-x-end

Present when there is overflow on the horizontal end side.

data-overflow-x-start

Present when there is overflow on the horizontal start side.

data-overflow-y-end

Present when there is overflow on the vertical end side.

data-overflow-y-start

Present when there is overflow on the vertical start side.

data-scrolling

Present when the user scrolls inside the scroll area.

--scroll-area-thumb-height

The scroll area thumb’s height.

--scroll-area-thumb-width

The scroll area thumb’s width.

CSS VariableDescription
--scroll-area-thumb-height

The scroll area thumb’s height.

--scroll-area-thumb-width

The scroll area thumb’s width.

ScrollArea.Scrollbar.PropsHide

Re-Export of Scrollbar props as ScrollAreaScrollbarProps

ScrollArea.Scrollbar.StateHide

Thumb

The draggable part of the scrollbar that indicates the current scroll position. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the scrollbar.

AttributeDescription
data-orientation

Indicates the orientation of the scrollbar.

ScrollArea.Thumb.PropsHide

Re-Export of Thumb props as ScrollAreaThumbProps

ScrollArea.Thumb.StateHide

Corner

A small rectangular area that appears at the intersection of horizontal and vertical scrollbars. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

ScrollArea.Corner.PropsHide

Re-Export of Corner props as ScrollAreaCornerProps

ScrollArea.Corner.StateHide