Scroll Area
A scrollable viewport with custom overlay scrollbars, edge fade masks, and overscroll containment built on Base UI.
Stack
Base UI
Tailwind CSS
Next.js
React
TypeScript
Class Variance Authority
Lucide Icons
Biome
Jotai
Fumadocs
Shiki
Zod
import { Card } from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
const tags = [
"Base UI",
"Tailwind CSS",
"Next.js",
"React",
"TypeScript",
"Class Variance Authority",
"Lucide Icons",
"Biome",
"Jotai",
"Fumadocs",
"Shiki",
"Zod",
];
export default function Particle() {
return (
<Card className="h-56 w-64 overflow-hidden">
<ScrollArea overscrollContain>
<div className="p-4">
<h4 className="mb-2 font-medium text-foreground text-sm">Stack</h4>
{tags.map((tag, index) => (
<div key={tag}>
<p className="py-2 text-muted-foreground text-sm">{tag}</p>
{index < tags.length - 1 && <Separator />}
</div>
))}
</div>
</ScrollArea>
</Card>
);
}
Installation
pnpm dlx shadcn@latest add @taut-ui/scroll-area
Usage
import { ScrollArea } from "@/components/ui/scroll-area"<ScrollArea className="h-56 w-64" scrollFade>
<div className="p-4">
{/* Scrollable content */}
</div>
</ScrollArea>Examples
Scroll Fade
ScrollArea applies smooth edge fade masks automatically whenever content overflows along the vertical or horizontal axis.
As you scroll down, the top mask fades in proportionally to the scroll offset, while the bottom mask fades out once you reach the end of the container.
Combined with overscrollContain, wheel and touch gestures stay contained inside the panel without pulling the parent page along.
Overlay scrollbars remain hidden at rest and appear cleanly on hover or active scrolling, keeping dense interfaces uncluttered.
import { Card } from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
export default function Particle() {
return (
<Card className="h-56 w-80 overflow-hidden">
<ScrollArea overscrollContain scrollFade>
<div className="space-y-3 p-5 text-muted-foreground text-sm leading-6">
<p>
ScrollArea applies smooth edge fade masks automatically whenever
content overflows along the vertical or horizontal axis.
</p>
<p>
As you scroll down, the top mask fades in proportionally to the
scroll offset, while the bottom mask fades out once you reach the
end of the container.
</p>
<p>
Combined with overscrollContain, wheel and touch gestures stay
contained inside the panel without pulling the parent page along.
</p>
<p>
Overlay scrollbars remain hidden at rest and appear cleanly on hover
or active scrolling, keeping dense interfaces uncluttered.
</p>
</div>
</ScrollArea>
</Card>
);
}
Horizontal
import { ScrollArea } from "@/components/ui/scroll-area";
const items = [
{ label: "Surface", value: "01" },
{ label: "Motion", value: "02" },
{ label: "Shape", value: "03" },
{ label: "Color", value: "04" },
{ label: "Type", value: "05" },
{ label: "Depth", value: "06" },
{ label: "Focus", value: "07" },
];
export default function Particle() {
return (
<div className="w-80">
<ScrollArea overscrollContain>
<div className="flex w-max gap-3 py-1">
{items.map((item) => (
<div
className="flex h-24 w-28 shrink-0 flex-col justify-between rounded-2xl bg-muted p-3.5 dark:bg-card"
key={item.value}
>
<span className="font-mono text-muted-foreground text-xs">
{item.value}
</span>
<span className="font-medium text-foreground text-sm">
{item.label}
</span>
</div>
))}
</div>
</ScrollArea>
</div>
);
}
Both Axes
import { Card } from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
const columns = ["Token", "Light", "Dark", "Taut", "Role"];
const rows = [
["--background", "#ffffff", "#121212", "oklch(0.19)", "Page canvas"],
["--foreground", "#262626", "#f5f5f5", "oklch(0.914)", "Primary text"],
["--card", "#ffffff", "#171717", "oklch(0.242)", "Surface low"],
["--popover", "#ffffff", "#1c1c1c", "oklch(0.284)", "Floating surface"],
["--primary", "#262626", "#f5f5f5", "oklch(0.827)", "Brand accent"],
["--secondary", "4% black", "4% white", "oklch(0.397)", "Tonal fill"],
["--muted", "4% black", "4% white", "oklch(0.284)", "Subtle surface"],
["--accent", "4% black", "4% white", "oklch(0.328)", "Hover surface"],
[
"--destructive",
"oklch(0.55)",
"oklch(0.58)",
"oklch(0.838)",
"Danger state",
],
["--ring", "#a3a3a3", "#737373", "oklch(0.827)", "Focus outline"],
];
export default function Particle() {
return (
<Card className="h-60 w-80 overflow-hidden">
<ScrollArea overscrollContain>
<div className="w-max p-4">
<div className="grid grid-cols-[9rem_6.5rem_6.5rem_7.5rem_8rem] gap-3 pb-2 font-medium text-foreground text-xs">
{columns.map((col) => (
<span key={col}>{col}</span>
))}
</div>
<div className="flex flex-col divide-y divide-border">
{rows.map((row) => (
<div
className="grid grid-cols-[9rem_6.5rem_6.5rem_7.5rem_8rem] gap-3 py-2 text-muted-foreground text-xs"
key={row[0]}
>
<span className="font-mono text-foreground">{row[0]}</span>
<span className="font-mono">{row[1]}</span>
<span className="font-mono">{row[2]}</span>
<span className="font-mono">{row[3]}</span>
<span>{row[4]}</span>
</div>
))}
</div>
</div>
</ScrollArea>
</Card>
);
}
Scrollbar Gutter
import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
const endpoints = [
{ method: "GET", path: "/api/projects", status: "200" },
{ method: "POST", path: "/api/deployments", status: "201" },
{ method: "GET", path: "/api/tokens", status: "200" },
{ method: "PATCH", path: "/api/settings", status: "200" },
{ method: "DELETE", path: "/api/sessions", status: "204" },
{ method: "GET", path: "/api/members", status: "200" },
{ method: "POST", path: "/api/invites", status: "201" },
{ method: "GET", path: "/api/webhooks", status: "200" },
{ method: "GET", path: "/api/audit-logs", status: "200" },
];
export default function Particle() {
return (
<Card className="h-56 w-80 overflow-hidden">
<ScrollArea overscrollContain scrollbarGutter>
<div className="flex flex-col gap-1 p-3">
{endpoints.map((ep) => (
<div
className="flex items-center justify-between gap-2 rounded-xl px-2.5 py-1.5 text-xs"
key={`${ep.method}-${ep.path}`}
>
<span className="truncate font-mono text-foreground">
<span className="me-2 text-muted-foreground">{ep.method}</span>
{ep.path}
</span>
<Badge size="sm" variant="success">
{ep.status}
</Badge>
</div>
))}
</div>
</ScrollArea>
</Card>
);
}
API Reference
ScrollArea
Wraps Base UI ScrollArea.Root, Viewport, Content, both vertical and horizontal ScrollBars, and Corner.
| Prop | Type | Default | Description |
|---|---|---|---|
scrollFade | boolean | false | Applies smooth edge fade masks along overflowing axes |
scrollbarGutter | boolean | false | Reserves padding along the scrollbar edge when content overflows |
fill | boolean | false | Expands the inner content wrapper to size-full |
clampContentMinWidth | boolean | true | Sets min-width: 0 on the content element to prevent flex overflow |
overscrollContain | boolean | false | Applies overscroll-contain on overflowing axes to stop scroll chaining |
className | string | - | Additional CSS classes applied to the root element |
...props | Base UI ScrollArea Root props | - | All other ScrollArea Root props are supported |
ScrollBar
Overlay scrollbar track and draggable thumb that appears on hover or active scrolling.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "vertical" | Scrollbar axis |
className | string | - | Additional CSS classes |
...props | Base UI Scrollbar props | - | All standard scrollbar attributes |