Skip to contents

Scroll Area

A native scroll container with custom scrollbars.

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 drive a CSS mask, which gradually increases the fade as the user scrolls away from the edges.

scroll-area.module.css

For SSR, a fallback can be used as part of the end-side var() call so the mask is visible before the overflow CSS variables hydrate.

SSR fallback

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

Child element opt-in

Combining with Tabs

Use <Tabs.List>'s render snippet to render <ScrollArea.Viewport> directly when the tab list itself needs the viewport overflow values for a mask fade. This keeps the mask logic on the same element that receives the scroll state.

Tabs with ScrollArea

API reference

Root

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

overflowEdgeThreshold OverflowEdgeThreshold 0
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
OverflowEdgeThreshold
Default
0
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaRootState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaRootState, children: Snippet | undefined]>
scrolling boolean
Name
scrolling
Description

Whether the scroll area is being scrolled.

Type
boolean
hasOverflowX boolean
Name
hasOverflowX
Description

Whether horizontal overflow is present.

Type
boolean
hasOverflowY boolean
Name
hasOverflowY
Description

Whether vertical overflow is present.

Type
boolean
overflowXStart boolean
Name
overflowXStart
Description

Whether there is overflow on the inline start side for the horizontal axis.

Type
boolean
overflowXEnd boolean
Name
overflowXEnd
Description

Whether there is overflow on the inline end side for the horizontal axis.

Type
boolean
overflowYStart boolean
Name
overflowYStart
Description

Whether there is overflow on the block start side.

Type
boolean
overflowYEnd boolean
Name
overflowYEnd
Description

Whether there is overflow on the block end side.

Type
boolean
cornerHidden boolean
Name
cornerHidden
Description

Whether the scrollbar corner is hidden.

Type
boolean
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.

Viewport

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

render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaViewportState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaViewportState, children: Snippet | undefined]>
scrolling boolean
Name
scrolling
Description

Whether the scroll area is being scrolled.

Type
boolean
hasOverflowX boolean
Name
hasOverflowX
Description

Whether horizontal overflow is present.

Type
boolean
hasOverflowY boolean
Name
hasOverflowY
Description

Whether vertical overflow is present.

Type
boolean
overflowXStart boolean
Name
overflowXStart
Description

Whether there is overflow on the inline start side for the horizontal axis.

Type
boolean
overflowXEnd boolean
Name
overflowXEnd
Description

Whether there is overflow on the inline end side for the horizontal axis.

Type
boolean
overflowYStart boolean
Name
overflowYStart
Description

Whether there is overflow on the block start side.

Type
boolean
overflowYEnd boolean
Name
overflowYEnd
Description

Whether there is overflow on the block end side.

Type
boolean
cornerHidden boolean
Name
cornerHidden
Description

Whether the scrollbar corner is hidden.

Type
boolean
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.

Content

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

render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaContentState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaContentState, children: Snippet | undefined]>
scrolling boolean
Name
scrolling
Description

Whether the scroll area is being scrolled.

Type
boolean
hasOverflowX boolean
Name
hasOverflowX
Description

Whether horizontal overflow is present.

Type
boolean
hasOverflowY boolean
Name
hasOverflowY
Description

Whether vertical overflow is present.

Type
boolean
overflowXStart boolean
Name
overflowXStart
Description

Whether there is overflow on the inline start side for the horizontal axis.

Type
boolean
overflowXEnd boolean
Name
overflowXEnd
Description

Whether there is overflow on the inline end side for the horizontal axis.

Type
boolean
overflowYStart boolean
Name
overflowYStart
Description

Whether there is overflow on the block start side.

Type
boolean
overflowYEnd boolean
Name
overflowYEnd
Description

Whether there is overflow on the block end side.

Type
boolean
cornerHidden boolean
Name
cornerHidden
Description

Whether the scrollbar corner is hidden.

Type
boolean
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.

Scrollbar

A vertical or horizontal scrollbar. Renders a <div> element.

orientation ScrollAxis 'vertical'
Description

Whether the scrollbar controls vertical or horizontal scroll.

Type
ScrollAxis
Default
'vertical'
keepMounted boolean false
Description

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

Type
boolean
Default
false
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaScrollbarState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaScrollbarState, children: Snippet | undefined]>
hovering boolean
Name
hovering
Description

Whether the scroll area is being hovered.

Type
boolean
scrolling boolean
Name
scrolling
Description

Whether this scrollbar's axis is being scrolled.

Type
boolean
orientation ScrollAxis
Name
orientation
Description

The orientation of the scrollbar.

Type
ScrollAxis
hasOverflowX boolean
Name
hasOverflowX
Description

Whether horizontal overflow is present.

Type
boolean
hasOverflowY boolean
Name
hasOverflowY
Description

Whether vertical overflow is present.

Type
boolean
overflowXStart boolean
Name
overflowXStart
Description

Whether there is overflow on the inline start side for the horizontal axis.

Type
boolean
overflowXEnd boolean
Name
overflowXEnd
Description

Whether there is overflow on the inline end side for the horizontal axis.

Type
boolean
overflowYStart boolean
Name
overflowYStart
Description

Whether there is overflow on the block start side.

Type
boolean
overflowYEnd boolean
Name
overflowYEnd
Description

Whether there is overflow on the block end side.

Type
boolean
cornerHidden boolean
Name
cornerHidden
Description

Whether the scrollbar corner is hidden.

Type
boolean
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.

Thumb

The draggable thumb that indicates the current scroll position. Renders a <div> element.

render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaThumbState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaThumbState, children: Snippet | undefined]>
scrolling boolean
Name
scrolling
Description

Whether this thumb's axis is being scrolled.

Type
boolean
orientation ScrollAxis
Name
orientation
Description

The component orientation.

Type
ScrollAxis
data-orientation
Indicates the orientation of the scrollbar.
data-scrolling
Present when the user scrolls inside the scroll area.

Corner

The rectangle where the horizontal and vertical scrollbars meet. Renders a <div> element.

render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaCornerState, children: Snippet | undefined]> —
Name
Description

Replace the default <div>. Spread props onto the host element.

Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ScrollAreaCornerState, children: Snippet | undefined]>