Scroll Area
A native scroll container with custom scrollbars.
View as MarkdownAnatomy
Import the component and assemble its parts:
import { ScrollArea } from '@base-ui-components/react/scroll-area';
<ScrollArea.Root>
  <ScrollArea.Viewport>
    <ScrollArea.Content />
  </ScrollArea.Viewport>
  <ScrollArea.Scrollbar>
    <ScrollArea.Thumb />
  </ScrollArea.Scrollbar>
  <ScrollArea.Corner />
</ScrollArea.Root>API reference
Root
Groups all parts of the scroll area.
Renders a <div> element.
overflowEdgeThresholdUnion
(default: 0
)
Union0- 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
- | number | { xStart?: number xEnd?: number yStart?: number yEnd?: number } | undefined
- Default
- 0
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: ScrollArea.Root.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Root.State, ) => ReactElement)
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.
--scroll-area-corner-height
The scroll area's corner height.
--scroll-area-corner-width
The scroll area's corner width.
--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.
Viewport
The actual scrollable container of the scroll area.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: ScrollArea.Viewport.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Viewport.State, ) => ReactElement)
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.
Content
A container for the content of the scroll area.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: ScrollArea.Content.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Content.State, ) => ReactElement)
Scrollbar
A vertical or horizontal scrollbar for the scroll area.
Renders a <div> element.
orientation'horizontal' | 'vertical'
(default: 'vertical'
)
'horizontal' | 'vertical''vertical'- Name
- Description
- Whether the scrollbar controls vertical or horizontal scroll. 
- Type
- 'horizontal' | 'vertical' | undefined
- Default
- 'vertical'
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: ScrollArea.Scrollbar.State) => string)
keepMountedboolean
(default: false
)
booleanfalse- Name
- Description
- Whether to keep the HTML element in the DOM when the viewport isn’t scrollable. 
- Type
- boolean | undefined
- Default
- false
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Scrollbar.State, ) => ReactElement)
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 users 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 part of the the scrollbar that indicates the current scroll position.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: ScrollArea.Thumb.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Thumb.State, ) => ReactElement)
data-orientation
Indicates the orientation of the scrollbar.
Corner
A small rectangular area that appears at the intersection of horizontal and vertical scrollbars.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: ScrollArea.Corner.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: ScrollArea.Corner.State, ) => ReactElement)