Scroll Area

Scroll Area creates a scrollable region with custom scrollbars.

Give FeedbackBundle Size

Introduction

User IDs

  • f47ac10b-58cc-4372-a567-0e02b2c3d479
  • 7c9e6679-7425-40de-944b-e07fc1f90ae7
  • 550e8400-e29b-41d4-a716-446655440000
  • 9b2b38e2-4c7b-4e53-a228-c89c535c5072
  • 3fa85f64-5717-4562-b3fc-2c963f66afa6
  • 4dfbdfc4-2d0e-4e6c-8bd6-7c8d765f0a1c
  • aa9e5d30-cf2a-4234-bc9b-6a5d965c6a00
  • 16fd2706-8baf-433b-82eb-8c7fada847da
  • 66ed7a57-e4b7-4b82-8b1e-2a8942f8ec6e
  • f9e87c8f-7b4f-4c7e-bb72-ebe8e2277c5e
index.tsx

Installation

Base UI components are all available as a single package.

npm install @base-ui-components/react

Once you have the package installed, import the component.

import { ScrollArea } from '@base-ui-components/react/scroll-area';

Anatomy

<ScrollArea.Root>
  <ScrollArea.Viewport />
  <ScrollArea.Scrollbar orientation="vertical">
    <ScrollArea.Thumb />
  </ScrollArea.Scrollbar>
  <ScrollArea.Scrollbar orientation="horizontal">
    <ScrollArea.Thumb />
  </ScrollArea.Scrollbar>
  <ScrollArea.Corner />
</ScrollArea.Root>

Styling

The scrollbar elements can be shown conditionally based on the user's interaction with the Scroll Area. The [data-scrolling] and [data-hovering] attributes are added to the scrollbar element while the user is scrolling or hovering over the Scroll Area.

.ScrollAreaScrollbar[data-scrolling],
.ScrollAreaScrollbar[data-hovering] {
  opacity: 1;
}

Inset scrollbars

By specifying a gutter prop, you can create inset scrollbars that make space for the scrollbar, preventing them from overlapping content. The value should match the size of the scrollbar width/height.

<ScrollArea.Root gutter={10}>

User IDs

  • f47ac10b-58cc-4372-a567-0e02b2c3d479
  • 7c9e6679-7425-40de-944b-e07fc1f90ae7
  • 550e8400-e29b-41d4-a716-446655440000
  • 9b2b38e2-4c7b-4e53-a228-c89c535c5072
  • 3fa85f64-5717-4562-b3fc-2c963f66afa6
  • 4dfbdfc4-2d0e-4e6c-8bd6-7c8d765f0a1c
  • aa9e5d30-cf2a-4234-bc9b-6a5d965c6a00
  • 16fd2706-8baf-433b-82eb-8c7fada847da
  • 66ed7a57-e4b7-4b82-8b1e-2a8942f8ec6e
  • f9e87c8f-7b4f-4c7e-bb72-ebe8e2277c5e
ScrollAreaInset.tsx

Corner

The vertical and horizontal scrollbar elements can prevent overlapping each other by rendering a Corner:

<ScrollArea.Scrollbar orientation="vertical" />
<ScrollArea.Scrollbar orientation="horizontal" />
<ScrollArea.Corner />

API Reference

ScrollAreaRoot

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
gutterunion0Determines the space to account for inset scrollbars.
renderunionA function to customize rendering of the component.

ScrollAreaViewport

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
renderunionA function to customize rendering of the component.

ScrollAreaScrollbar

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
keepMountedboolfalseWhether the scrollbars remain mounted in the DOM when there is no overflow.
orientationenum'vertical'The orientation of the scrollbar.
renderunionA function to customize rendering of the component.

ScrollAreaThumb

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
renderunionA function to customize rendering of the component.

ScrollAreaCorner

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
renderunionA function to customize rendering of the component.

Contents