Skip to content

ScrollArea

Themed, cross-browser scroll container with custom scrollbars — keeps long content contained without breaking native scroll semantics.

  • stable
  • since v0.1.0
  • 1.0 kB
  • data-display
  • scroll
  • radix

Falls back to native scrolling behaviour; keyboard scrolling (arrow keys, Page Up/Down, Home/End) is preserved.

Preview
Open
tsx

Set scrollbars="horizontal" for an x-axis scroll region — pair with a wide inner container that overflows the viewport width.

Preview
Open
tsx

The default scrollbars="both" renders thumbs on both axes; a corner element fills the intersection.

Preview
Open
tsx

The type prop controls when the scrollbars appear: hover (default), auto, always, or scroll.

Preview
Open
tsx
PropTypeDefaultDescription
type
"auto"|"always"|"hover"
auto
When scrollbars are visible. - `auto` (default): browser default — scrollbar appears when content overflows. - `always`: reserved gutter even when no overflow. - `hover`: scrollbars become visible on pointer over via CSS.
height
string|number
Convenience for the viewport height (number is converted to `px`).
width
string|number
Convenience for the viewport width (number is converted to `px`).
children
ReactNode
Scrollable content.
scrollbars
"vertical"|"horizontal"|"both"
both
Which scrollbars to render — useful to suppress the orthogonal axis.
  • Preserves native scroll mechanics — keyboard scrolling (arrow keys, PageUp / PageDown, Home / End) works without extra wiring.
  • Custom scrollbars are decorative; the underlying content remains the source of truth for assistive tech.
  • Honours prefers-reduced-motion for thumb fade transitions.
  • Pass aria-label (or aria-labelledby) when the scroll region’s purpose is not clear from surrounding context.
  • Wheel and pointer scrolling continue to work even when the custom scrollbars are hidden.
  • Set scrollbars="vertical" or "horizontal" to constrain the scroll axis to a single direction.
  • Combine with CodeBlock to keep long snippets contained inside a fixed height.
  • Use type="always" to keep the scrollbars visible at all times (e.g. macOS users who hide them by default).
  • Pass width and height directly for an inline-sized scroll region without writing extra styles.