Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Scroll Area for React and Tailwind

Custom scrollable area with styled scrollbars.

Installation

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

Anatomy

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

Usage

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

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

Accessibility

KeyDescription
Enter
Activate the focused item.

Demos

Both Directions

Horizontal

Nested

Scroll Fade

API Reference

ScrollArea

div

PropType
AttributeType
CSS variableType

ScrollAreaViewport

div

PropType

ScrollAreaContent

div

PropType

ScrollAreaScrollbar

div

PropType
AttributeType

ScrollAreaThumb

div

PropType

ScrollAreaCorner

div

PropType

useScrollArea