Radix homepage
Components

Scroll Area

Augments native scroll functionality for custom, cross-browser styling.

import React from 'react';
import * as ScrollArea from '@radix-ui/react-scroll-area';
import './styles.css';
const TAGS = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`);
const ScrollAreaDemo = () => (
<ScrollArea.Root className="ScrollAreaRoot">
<ScrollArea.Viewport className="ScrollAreaViewport">
<div style={{ padding: '15px 20px' }}>
<div className="Text">Tags</div>
{TAGS.map((tag) => (
<div className="Tag" key={tag}>
{tag}
</div>
))}
</div>
</ScrollArea.Viewport>
<ScrollArea.Scrollbar className="ScrollAreaScrollbar" orientation="vertical">
<ScrollArea.Thumb className="ScrollAreaThumb" />
</ScrollArea.Scrollbar>
<ScrollArea.Scrollbar className="ScrollAreaScrollbar" orientation="horizontal">
<ScrollArea.Thumb className="ScrollAreaThumb" />
</ScrollArea.Scrollbar>
<ScrollArea.Corner className="ScrollAreaCorner" />
</ScrollArea.Root>
);
export default ScrollAreaDemo;

Features

  • Scrollbar sits on top of the scrollable content, taking up no space.
  • Scrolling is native; no underlying position movements via CSS transformations.
  • Shims pointer behaviors only when interacting with the controls, so keyboard controls are unaffected.
  • Supports Right to Left direction.

Install the component from your command line.

npm install @radix-ui/react-scroll-area

Import all parts and piece them together.

import * as ScrollArea from '@radix-ui/react-scroll-area';
export default () => (
<ScrollArea.Root>
<ScrollArea.Viewport />
<ScrollArea.Scrollbar orientation="horizontal">
<ScrollArea.Thumb />
</ScrollArea.Scrollbar>
<ScrollArea.Scrollbar orientation="vertical">
<ScrollArea.Thumb />
</ScrollArea.Scrollbar>
<ScrollArea.Corner />
</ScrollArea.Root>
);

Contains all the parts of a scroll area.

PropTypeDefault
asChildbooleanfalse
typeenum"hover"
scrollHideDelaynumber600
direnumNo default value

The viewport area of the scroll area.

PropTypeDefault
asChildbooleanfalse

The vertical scrollbar. Add a second Scrollbar with an orientation prop to enable horizontal scrolling.

PropTypeDefault
asChildbooleanfalse
forceMountbooleanNo default value
orientationenumvertical
Data AttributeValues
[data-state]"visible" | "hidden"
[data-orientation]"vertical" | "horizontal"

The thumb to be used in ScrollArea.Scrollbar.

PropTypeDefault
asChildbooleanfalse
Data AttributeValues
[data-state]"visible" | "hidden"

The corner where both vertical and horizontal scrollbars meet.

PropTypeDefault
asChildbooleanfalse

In most cases, it's best to rely on native scrolling and work with the customization options available in CSS. When that isn't enough, ScrollArea provides additional customizability while maintaining the browser's native scroll behavior (as well as accessibiliy features, like keyboard scrolling).

Scrolling via keyboard is supported by default because the component relies on native scrolling. Specific keyboard interactions may differ between platforms, so we do not specify them here or add specific event listeners to handle scrolling via key events.