ZaidanHomeDocsComponentsBlocksChartsTypesetCreate

Command Palette

Search for a command to run...

GitHub
New
Sections
  • Introduction
  • Components
  • Blocks
  • Installation
  • Customization
  • Dark Mode
  • Typeset
  • Zaidan Skills
  • FAQ
  • Roadmap
  • Changelog
Installation
  • Astro
  • Manual
  • Solid Start
  • TanStack Router
  • TanStack Start
  • Vite
Blocks
  • Data Grid
  • Event Calendar
  • Filters
  • Gantt
  • Image Crop
  • Kanban
  • Message Scroller
  • Questionnaire
  • Sortable
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • Native Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Radio Group
  • Resizable
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip

Scroll Area

Augments native scroll functionality for custom, cross-browser styling.

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
1
import { For } from "solid-js";
2
import { ScrollArea } from "~/components/ui/scroll-area";
3
import { Separator } from "~/components/ui/separator";
4
5
const tags = Array.from({ length: 50 }).map(
6
(_, index, array) => `v1.2.0-beta.${array.length - index}`,
7
);
8
9
export default function ScrollAreaDemo() {
10
return (
11
<ScrollArea class="h-72 w-48 rounded-md border">
12
<div class="p-4">
13
<h4 class="mb-4 font-medium text-sm leading-none">Tags</h4>
14
<For each={tags}>
15
{(tag) => (
16
<>
17
<div class="text-sm">{tag}</div>
18
<Separator class="my-2" />
19
</>
20
)}
21
</For>
22
</div>
23
</ScrollArea>
24
);
25
}

Installation

pnpm dlx shadcn@latest add @zaidan/scroll-area
npx shadcn@latest add @zaidan/scroll-area
yarn dlx shadcn@latest add @zaidan/scroll-area
bunx --bun shadcn@latest add @zaidan/scroll-area

Usage

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

Composition

ScrollArea renders its own viewport and a vertical ScrollBar internally, so most usages only need the root:

ScrollArea
└── ScrollBar (horizontal, opt-in)

Horizontal

Add a ScrollBar with orientation="horizontal" as a direct child for horizontal scrolling. The vertical scrollbar is always present internally and simply stays hidden when its axis doesn't overflow.

Photo by Ornella Binni
Photo by Ornella Binni
Photo by Tom Byrom
Photo by Tom Byrom
Photo by Vladimir Malyavko
Photo by Vladimir Malyavko
1
/** biome-ignore-all lint/a11y/noRedundantAlt: upstream demo describes each photograph */
2
import { For } from "solid-js";
3
import { ScrollArea, ScrollBar } from "~/components/ui/scroll-area";
4
5
const artworks = [
6
{
7
artist: "Ornella Binni",
8
art: "https://images.unsplash.com/photo-1465869185982-5a1a7522cbcb?auto=format&fit=crop&w=300&q=80",
9
},
10
{
11
artist: "Tom Byrom",
12
art: "https://images.unsplash.com/photo-1548516173-3cabfa4607e9?auto=format&fit=crop&w=300&q=80",
13
},
14
{
15
artist: "Vladimir Malyavko",
16
art: "https://images.unsplash.com/photo-1494337480532-3725c85fd2ab?auto=format&fit=crop&w=300&q=80",
17
},
18
] as const;
19
20
export default function ScrollAreaHorizontalDemo() {
21
return (
22
<ScrollArea class="w-96 rounded-md border whitespace-nowrap">
23
<div class="flex w-max space-x-4 p-4">
24
<For each={artworks}>
25
{(artwork) => (
26
<figure class="shrink-0">
27
<div class="overflow-hidden rounded-md">
28
<img
29
src={artwork.art}
30
alt={`Photo by ${artwork.artist}`}
31
class="aspect-[3/4] h-fit w-fit object-cover"
32
width={300}
33
height={400}
34
/>
35
</div>
36
<figcaption class="pt-2 text-xs text-muted-foreground">
37
Photo by <span class="font-semibold text-foreground">{artwork.artist}</span>
38
</figcaption>
39
</figure>
40
)}
41
</For>
42
</div>
43
<ScrollBar orientation="horizontal" />
44
</ScrollArea>
45
);
46
}

API Reference

ScrollArea

The root container. It renders a scrollable viewport around its children, a vertical ScrollBar, and a corner element, and shows/hides scrollbars based on hover state and overflow.

PropTypeDefault
classstring-
childrenJSX.Element-

All other props are forwarded to the root div.

ScrollBar

A scrollbar track and thumb for one axis. It is always mounted, but stays visually hidden (opacity-0, non-interactive) unless its axis overflows and the scroll area is hovered or the thumb is being dragged.

PropTypeDefault
orientation"vertical" | "horizontal""vertical"
classstring-

ScrollArea is a native SolidJS implementation and does not build on a Kobalte or Corvu primitive, so it does not expose a primitive API to link to.

On This Page

  • Installation
  • Usage
  • Composition
  • Horizontal
  • API Reference
    • ScrollArea
    • ScrollBar
Built by Kevin Abatan. The source code is available on GitHub.