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
Corner handling, context management, and advanced configuration options for complex scroll area implementations.
Corner element that fills the space when both horizontal and vertical scrollbars are visible.
const ScrollAreaCorner: React.ForwardRefExoticComponent<
ScrollAreaCornerProps & React.RefAttributes<ScrollAreaCornerElement>
>;
interface ScrollAreaCornerProps extends React.ComponentPropsWithoutRef<"div"> {}
type ScrollAreaCornerElement = React.ComponentRef<"div">;Usage Examples:
import { ScrollAreaCorner } from "@radix-ui/react-scroll-area";
// Basic corner (automatically shown when both scrollbars are visible)
<ScrollArea>
<ScrollAreaViewport>
<div>Large content requiring both scrollbars</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
<ScrollAreaScrollbar orientation="horizontal">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
<ScrollAreaCorner />
</ScrollArea>
// Styled corner
<ScrollAreaCorner
style={{
backgroundColor: '#f0f0f0',
borderRadius: '2px'
}}
/>Advanced context system for nested scroll areas and component coordination.
/**
* Creates a scoped context for scroll area components
* Enables multiple scroll areas to coexist without context conflicts
* @returns Scope object for nested scroll area instances
*/
function createScrollAreaScope(): Scope;Usage Examples:
import { createScrollAreaScope, ScrollArea } from "@radix-ui/react-scroll-area";
// Create isolated scope for nested scroll areas
const ScrollAreaScope = createScrollAreaScope();
function NestedScrollAreas() {
return (
<ScrollArea>
<ScrollAreaViewport>
<div>
<p>Outer scroll area content</p>
<ScrollArea __scopeScrollArea={ScrollAreaScope}>
<ScrollAreaViewport __scopeScrollArea={ScrollAreaScope}>
<div>Inner scroll area content</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar __scopeScrollArea={ScrollAreaScope}>
<ScrollAreaThumb __scopeScrollArea={ScrollAreaScope} />
</ScrollAreaScrollbar>
</ScrollArea>
</div>
</ScrollAreaViewport>
<ScrollAreaScrollbar>
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>
);
}Advanced feature aliases for shorter imports.
const Corner: typeof ScrollAreaCorner;Usage Examples:
import { Corner } from "@radix-ui/react-scroll-area";
<Corner />The scroll area components include several performance optimizations:
-webkit-scrollbar, -ms-overflow-style, and scrollbar-widthInternal state machine system for complex scrollbar visibility states:
// Internal state machine states (not exported)
type ScrollbarState = "hidden" | "scrolling" | "interacting" | "idle";States transition based on user interaction:
hidden → scrolling (on scroll)scrolling → idle (on scroll end)idle → hidden (after delay)interacting → idle (on pointer leave)Advanced CSS custom properties for precise styling control:
.scroll-area {
--radix-scroll-area-corner-width: /* corner width in px */;
--radix-scroll-area-corner-height: /* corner height in px */;
--radix-scroll-area-thumb-width: /* horizontal thumb width in px */;
--radix-scroll-area-thumb-height: /* vertical thumb height in px */;
}The component gracefully handles edge cases:
Advanced accessibility considerations:
prefers-reduced-motion for smooth scrollingInstall with Tessl CLI
npx tessl i tessl/npm-radix-ui--react-scroll-area