Skip to content

Scroll Area

A scrollable container with custom, cross-browser scrollbars for chat panes, sidebars, and file trees — with a chunky neobrutalist thumb.

import * as React from "react"

import { ScrollArea } from "@/components/ui/scroll-area"

The scroll area replaces the browser's default scrollbars with ones you style — native scrolling stays underneath, so wheel, touch, and momentum behavior are untouched. Built on the Base UI Scroll Area component and styled to the neobrutalist recipe: a solid, chunky thumb in the border color and a hard focus ring on the viewport.

Reach for it when:

  • Chat and log panes — fix the height and let messages scroll inside the panel, not the page.
  • Sidebars and file trees — long navigation lists that scroll independently of the main content.
  • Horizontal strips — tag rows, card galleries, and wide tables via orientation="horizontal".

Installation

pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/scroll-area.json
npx shadcn@latest add https://neobrutalism.com/r/base/scroll-area.json
yarn dlx shadcn@latest add https://neobrutalism.com/r/base/scroll-area.json
bunx --bun shadcn@latest add https://neobrutalism.com/r/base/scroll-area.json

Install the following dependencies:

pnpm add @base-ui/react
npm install @base-ui/react
yarn add @base-ui/react
bun add @base-ui/react

Copy and paste the following code into your project.

components/ui/scroll-area.tsx
"use client"

import * as React from "react"
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui"

import { cn } from "@/lib/utils"

function ScrollArea({
  className,
  children,
  ...props
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
  return (
    <ScrollAreaPrimitive.Root
      data-slot="scroll-area"
      className={cn("relative", className)}
      {...props}
    >
      <ScrollAreaPrimitive.Viewport
        data-slot="scroll-area-viewport"
        className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
      >
        {children}
      </ScrollAreaPrimitive.Viewport>
      <ScrollBar />
      <ScrollAreaPrimitive.Corner />
    </ScrollAreaPrimitive.Root>
  )
}

function ScrollBar({
  className,
  orientation = "vertical",
  ...props
}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
  return (
    <ScrollAreaPrimitive.ScrollAreaScrollbar
      data-slot="scroll-area-scrollbar"
      data-orientation={orientation}
      orientation={orientation}
      className={cn(
        "flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",
        className
      )}
      {...props}
    >
      <ScrollAreaPrimitive.ScrollAreaThumb
        data-slot="scroll-area-thumb"
        className="relative flex-1 rounded bg-border"
      />
    </ScrollAreaPrimitive.ScrollAreaScrollbar>
  )
}

export { ScrollArea, ScrollBar }

Update the import paths to match your project setup.

Usage

import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"
<ScrollArea className="h-[200px] w-[350px] rounded-md border p-4">
  Your scrollable content here.
</ScrollArea>

Composition

Use the following composition to build a ScrollArea:

ScrollArea
└── ScrollBar

Examples

Horizontal

Use ScrollBar with orientation="horizontal" for horizontal scrolling.

import * as React from "react"
import Image from "next/image"

RTL

To enable RTL support in Neobrutalism.com, see the RTL configuration guide.

"use client"

import * as React from "react"

Accessibility

There is no WAI-ARIA pattern for scroll areas — none is needed, because the Base UI component keeps a real native scroll container underneath, so wheel, touch, and keyboard scrolling behave exactly as the browser's own. Not every browser makes a scroll container keyboard-focusable by itself: if the content contains no focusable elements, add tabIndex={0} and an aria-label to the viewport so keyboard users can reach and scroll it — the styles already include a visible focus ring for that case. The custom scrollbar and thumb are pointer-only affordances; they must never be the only way to scroll.

API Reference

See the Base UI Scroll Area documentation.