RadCN
Layoutreadycomponentready

Scroll Area

A native scroll container primitive with viewport, scrollbar, thumb, corner, focus, and app-owned content composition.

Importimport { ScrollArea, ScrollAreaViewport, ScrollBar } from 'radcn/scroll-area'
Preview

Live package example

Render the upstream tag list and horizontal artwork Scroll Area examples with native scrolling and deterministic non-network artwork.

Example Parity

Render the upstream tag list and horizontal artwork Scroll Area examples with native scrolling and deterministic non-network artwork.

Preview

Tags

v1.2.0-beta.50
v1.2.0-beta.49
v1.2.0-beta.48
v1.2.0-beta.47
v1.2.0-beta.46
v1.2.0-beta.45
v1.2.0-beta.44
v1.2.0-beta.43
v1.2.0-beta.42
v1.2.0-beta.41
v1.2.0-beta.40
v1.2.0-beta.39
v1.2.0-beta.38
v1.2.0-beta.37
v1.2.0-beta.36
v1.2.0-beta.35
v1.2.0-beta.34
v1.2.0-beta.33
v1.2.0-beta.32
v1.2.0-beta.31
v1.2.0-beta.30
v1.2.0-beta.29
v1.2.0-beta.28
v1.2.0-beta.27
v1.2.0-beta.26
v1.2.0-beta.25
v1.2.0-beta.24
v1.2.0-beta.23
v1.2.0-beta.22
v1.2.0-beta.21
v1.2.0-beta.20
v1.2.0-beta.19
v1.2.0-beta.18
v1.2.0-beta.17
v1.2.0-beta.16
v1.2.0-beta.15
v1.2.0-beta.14
v1.2.0-beta.13
v1.2.0-beta.12
v1.2.0-beta.11
v1.2.0-beta.10
v1.2.0-beta.9
v1.2.0-beta.8
v1.2.0-beta.7
v1.2.0-beta.6
v1.2.0-beta.5
v1.2.0-beta.4
v1.2.0-beta.3
v1.2.0-beta.2
v1.2.0-beta.1
Photo by Ornella Binni
Photo by Ornella Binni
Photo by Tom Byrom
Photo by Tom Byrom
Photo by Vladimir Malyavko
Photo by Vladimir Malyavko
import { ScrollArea, ScrollAreaThumb, ScrollAreaViewport, ScrollBar } from 'radcn/scroll-area'
import { Separator } from 'radcn/separator'

const tags = Array.from({ length: 50 }, (_, index) => `v1.2.0-beta.${50 - index}`)

const artworks = [
  { artist: 'Ornella Binni', src: 'data:image/svg+xml,...' },
  { artist: 'Tom Byrom', src: 'data:image/svg+xml,...' },
  { artist: 'Vladimir Malyavko', src: 'data:image/svg+xml,...' },
]

export function ScrollAreaPreview() {
  return (
    <>
      <ScrollArea style="width:12rem;height:18rem;">
        <ScrollAreaViewport ariaLabel="Tags">
          <div style="padding:1rem;">
            <h4>Tags</h4>
            {tags.map((tag, index) => (
              <>
                <div>{tag}</div>
                {index < tags.length - 1 && <Separator />}
              </>
            ))}
          </div>
        </ScrollAreaViewport>
        <ScrollBar><ScrollAreaThumb /></ScrollBar>
      </ScrollArea>

      <ScrollArea style="width:24rem;">
        <ScrollAreaViewport ariaLabel="Artwork gallery">
          <div style="display:flex;width:max-content;gap:1rem;padding:1rem;white-space:nowrap;">
            {artworks.map((artwork) => (
              <figure>
                <img src={artwork.src} alt={`Photo by ${artwork.artist}`} width="300" height="400" />
                <figcaption>Photo by <strong>{artwork.artist}</strong></figcaption>
              </figure>
            ))}
          </div>
        </ScrollAreaViewport>
        <ScrollBar orientation="horizontal"><ScrollAreaThumb /></ScrollBar>
      </ScrollArea>
    </>
  )
}

Installation

Intended future install command. RadCN is private and not published to npm yet, so this snippet documents the target user-facing API rather than something external consumers can run today.

pnpm add radcn # intended future package
import { ScrollArea, ScrollAreaViewport, ScrollBar } from 'radcn/scroll-area'

Theming

RadCN tokens read the resolved theme from the document. Store the user's preference separately, then resolve system preferences to a concrete light or dark theme before setting package tokens.

<html data-radcn-theme-mode="system" data-radcn-theme="dark">
  ...
</html>

Accessibility

  • ScrollAreaViewport is focusable by default and can provide an ariaLabel for named scroll regions.
  • Native overflow owns keyboard, pointer, and assistive-technology scroll behavior without a client-side scroll engine.
  • Scrollbar, thumb, and corner parts are aria-hidden presentation while the viewport remains the accessible scroll container.
  • Figure, figcaption, image alt text, headings, tag text, and Separator semantics remain authored content inside the viewport.

Customization

  • ScrollArea exposes root, viewport, scrollbar, thumb, and corner hooks through data-radcn-scroll-area* attributes and package classes.
  • Use class, style, and CSS variables to tune width, height, border, radius, background, thumb color, and corner color.
  • Use ScrollBar orientation="horizontal" when an example needs explicit horizontal scroll affordance.
  • Repeated content, Separator rows, image presentation, whitespace, max-content strip layout, and spacing stay app-owned composition.

Remix 3 Notes

  • React props, Radix ScrollAreaPrimitive, className, data-slot, Tailwind utilities, and cn map to explicit RadCN props, class, public data hooks, package CSS, inline style, and CSS variables.
  • The upstream default vertical ScrollBar maps to explicit ScrollBar composition in RadCN examples.
  • React fragments and keys are upstream rendering mechanics; RadCN examples render ordinary repeated markup.
  • next/image, remote Unsplash URLs, and image optimization are app presentation concerns, not RadCN dependencies.
  • The horizontal artwork example uses deterministic non-network artwork data so tests do not depend on remote image loading.
  • vendor source remains read-only evidence and is not imported by RadCN.