A React component for creating accessible scroll areas with customizable scrollbars
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Customizable scrollbar components that support multiple display modes, orientations, and accessibility features.
The scrollbar component that handles scrolling interaction for both horizontal and vertical orientations.
const ScrollAreaScrollbar: React.ForwardRefExoticComponent<
ScrollAreaScrollbarProps & React.RefAttributes<ScrollAreaScrollbarElement>
>;
interface ScrollAreaScrollbarProps extends React.ComponentPropsWithoutRef<"div"> {
/**
* Scrollbar orientation
* @default "vertical"
*/
orientation?: "horizontal" | "vertical"; // default: "vertical"
/**
* Force mount the scrollbar regardless of visibility conditions
* Useful for controlling animation with React animation libraries
*/
forceMount?: true;
}
type ScrollAreaScrollbarElement = React.ComponentRef<"div">;Usage Examples:
import { ScrollAreaScrollbar } from "@radix-ui/react-scroll-area";
// Vertical scrollbar (default)
<ScrollAreaScrollbar>
<ScrollAreaThumb />
</ScrollAreaScrollbar>
// Horizontal scrollbar
<ScrollAreaScrollbar orientation="horizontal">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
// Force mounted scrollbar for animation control
<ScrollAreaScrollbar forceMount>
<ScrollAreaThumb />
</ScrollAreaScrollbar>The draggable handle component within scrollbars that represents the current scroll position.
const ScrollAreaThumb: React.ForwardRefExoticComponent<
ScrollAreaThumbProps & React.RefAttributes<ScrollAreaThumbElement>
>;
interface ScrollAreaThumbProps extends React.ComponentPropsWithoutRef<"div"> {
/**
* Force mount the thumb regardless of visibility conditions
* Useful for controlling animation with React animation libraries
* @default undefined
*/
forceMount?: true;
}
type ScrollAreaThumbElement = React.ComponentRef<"div">;Usage Examples:
import { ScrollAreaThumb } from "@radix-ui/react-scroll-area";
// Basic thumb
<ScrollAreaThumb />
// Force mounted thumb for animation control
<ScrollAreaThumb forceMount />
// Styled thumb
<ScrollAreaThumb
style={{
backgroundColor: '#666',
borderRadius: 4
}}
/>Shorter alias components for scrollbar system.
const Scrollbar: typeof ScrollAreaScrollbar;
const Thumb: typeof ScrollAreaThumb;Usage Examples:
import { Scrollbar, Thumb } from "@radix-ui/react-scroll-area";
<Scrollbar orientation="vertical">
<Thumb />
</Scrollbar>Shows scrollbars only when content overflows the viewport.
<ScrollArea type="auto">
<ScrollAreaViewport>
<div>Content</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>Always shows scrollbars regardless of content overflow.
<ScrollArea type="always">
<ScrollAreaViewport>
<div>Content</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>Shows scrollbars during scroll events and user interaction.
<ScrollArea type="scroll">
<ScrollAreaViewport>
<div>Content</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>Shows scrollbars when hovering over the scroll area (default behavior).
<ScrollArea type="hover" scrollHideDelay={1000}>
<ScrollAreaViewport>
<div>Content</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>Scrollbars are automatically positioned based on text direction:
Components include data attributes for styling:
data-orientation="horizontal|vertical" on scrollbarsdata-state="visible|hidden" indicating current visibilitydata-radix-scroll-area-viewport on viewport elementsInstall with Tessl CLI
npx tessl i tessl/npm-radix-ui--react-scroll-area