Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Scroll Area for React

Custom scrollable area with styled scrollbars.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/base/scroll-area.json

Anatomy

ScrollArea
├── ScrollAreaViewport
├── ScrollAreaContent
├── ScrollAreaScrollbar
│   └── ScrollAreaThumb
└── ScrollAreaCorner

Usage

import { Fragment } from "react";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
const tags = Array.from({ length: 50 }).map(
  (_, i, a) => `v1.2.0-beta.${a.length - i}`
);

const ScrollAreaDemo = () => (
  <ScrollArea className="h-72 w-48 rounded-md border">
    <div className="p-4">
      <h4 className="mb-4 font-medium text-sm leading-none">Tags</h4>
      {tags.map((tag) => (
        <Fragment key={tag}>
          <div className="text-sm">{tag}</div>
          <Separator className="my-2" />
        </Fragment>
      ))}
    </div>
  </ScrollArea>
);

Accessibility

KeyDescription
Enter
Activate the focused item.

Demos

Horizontal

Horizontal scrolling artwork strip.

Rtl

Right-to-left scroll area. See the RTL configuration guide for document direction.

API Reference

ScrollArea

div

PropType
AttributeType
CSS variableType
--corner-heightstring
--corner-widthstring
--thumb-heightstring
--thumb-widthstring

ScrollAreaViewport

div

AttributeType

ScrollBar

div

PropType
AttributeType

ScrollAreaThumb

div

AttributeType

ScrollAreaCorner

div

AttributeType