Scroll Area
Augments native scroll functionality for custom styling.
When to Use
Use Scroll Area when you need to:
- Display long lists, logs, or text content in a fixed-height container
- Provide custom-styled scrollbars that match your design system
- Create horizontal scrolling galleries or carousels without native scrollbar aesthetics
- Contain overflowing content in sidebars, panels, or modals
- Support both vertical and horizontal scrolling in data-heavy layouts
When Not to Use
- Full-page scrolling -- use native browser scroll instead
- Content that should be fully visible -- avoid hiding content behind scroll when space allows
- Single-line horizontal overflow -- consider
text-ellipsisor a Tooltip - Paginated data -- use Pagination or Data Table for large datasets
Vertical List
Scrollable list with custom styled scrollbar. Set an explicit height on the container for vertical scrolling to activate.
Horizontal Scrolling
Horizontal scroll area for galleries or wide content. Add a ScrollBar with orientation='horizontal' and use whitespace-nowrap on the container.
Text Content
Scrollable text content area for articles, documentation, or long descriptions within constrained space.
Always Visible Scrollbar
Use type='always' to keep scrollbars visible at all times, making it clear the content is scrollable.
Both Axes
Scroll area supporting both vertical and horizontal scrolling. Useful for wide tables or grid content in constrained containers.
UX & Design Guidelines
Visual Hierarchy
Scroll areas should have clear boundaries using border border-border and rounded-md to signal containment. The scrollbar thumb uses bg-border for subtlety, becoming more visible on hover. Use type="always" when discoverability of hidden content is critical.
Spacing & Layout
Always set explicit dimensions on the ScrollArea container ( h-72, h-[200px]). Apply padding to the inner content wrapper rather than the ScrollArea itself to avoid clipping scrollbar tracks. Use p-4 on the child container for consistent content insets.
Responsive Behavior
On mobile, the scrollbar is narrower (2.5 units wide) for minimal visual footprint. Consider using percentage-based or viewport-relative heights ( h-[50vh]) for responsive scroll containers. Horizontal scroll areas should use whitespace-nowrap with touch-friendly scrollbar sizing.
Color & Contrast
The scrollbar thumb uses the bg-border semantic token, which adapts to light and dark mode automatically. Scrollbar tracks use transparent borders ( border-l-transparent) for clean alignment. The custom scrollbar provides consistent styling across browsers while maintaining sufficient contrast for visibility.
Accessibility
Keyboard Navigation
- Tab -- Move focus into the scroll area viewport
- Arrow Up / Arrow Down -- Scroll vertically when the viewport is focused
- Arrow Left / Arrow Right -- Scroll horizontally when a horizontal scrollbar is present
- Page Up / Page Down -- Scroll by one viewport height
- Home / End -- Jump to the start or end of the scrollable content
Screen Reader Support
- The viewport is focusable and announces its scrollable nature to assistive technology
- Custom scrollbars are purely decorative -- screen readers use native scroll semantics
- Use
aria-labelon the ScrollArea to describe its content region - For live-updating content (e.g., chat logs), add
aria-live="polite"orrole="log"
Focus Management
The viewport uses focus-visible:ring-[3px] with ring-ring/50 for a visible focus indicator. Focus is applied to the viewport element, not the outer container, so keyboard users can immediately scroll. The focus ring inherits the container's border radius via rounded-[inherit].
RTL Support
Set dir="rtl" on the ScrollArea to enable right-to-left scroll behavior. Horizontal scrollbars will reverse direction to match the reading order. Content within the scroll area should also be set to RTL for consistent layout.
ARIA Attributes
{/* Standard scrollable region with accessible label */}
<ScrollArea className="h-72 w-48 rounded-md border" aria-label="Version tags">
{/* Content */}
</ScrollArea>
{/* Scroll area within a labeled section */}
<section aria-labelledby="notifications-heading">
<h2 id="notifications-heading">Notifications</h2>
<ScrollArea className="h-[300px]">
{/* Notification list */}
</ScrollArea>
</section>
{/* Scroll area with role and description */}
<ScrollArea
className="h-[200px]"
role="log"
aria-label="Activity log"
aria-live="polite"
>
{/* Live-updating log content */}
</ScrollArea>Related Components
Resizable
Resizable panel groups that pair well with scroll areas for adjustable content regions.
Table
Wrap tables in a scroll area for horizontally overflowing data with custom scrollbars.
Card
Use scroll areas inside cards for contained, scrollable content with structured headers and footers.
Separator
Visually divide items within a scrollable list for clearer content separation.
API Reference
The ScrollArea component accepts the following props in addition to standard div attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "auto" | "always" | "scroll" | "hover" | "hover" | Determines when scrollbars are visible. 'auto' shows when content overflows, 'always' keeps them visible, 'scroll' shows on scroll, 'hover' shows on hover. |
| scrollHideDelay | number | 600 | Duration in milliseconds before scrollbars auto-hide after the user stops scrolling. Only applies when type is 'scroll' or 'hover'. |
| dir | "ltr" | "rtl" | "ltr" | The reading direction of the scroll area. Affects horizontal scroll behavior. |
| className | string | — | Additional CSS classes to apply to the scroll area container. |
ScrollBar
The ScrollBar sub-component controls individual scrollbar tracks. A vertical ScrollBar is rendered by default.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "vertical" | "horizontal" | "vertical" | The axis the scrollbar controls. A vertical ScrollBar is included by default. |
| forceMount | boolean | false | When true, forces the scrollbar to render even when content does not overflow. |
| className | string | — | Additional CSS classes to apply to the scrollbar element. |