# Scroll Area

A scrolling region with its scrollbars drawn by hand: a faint pen line for the track, a heavier doubled one for the thumb.

Docs: https://ballpoint.st9wd.com/docs/scroll-area

```bash
npx shadcn@latest add @ballpoint/scroll-area
```

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

<ScrollArea className="h-72 w-56">
  …long content…
</ScrollArea>
```

Props:

- `className`: `string`. Size the area (a height or width is needed for it to scroll).
- `seed`: `string | number`. Pins the drawing of the scrollbars.

Pen settings: `weight`, `speed` (see Pen settings).

Every other prop goes to Base UI's Scroll Area: https://base-ui.com/react/components/scroll-area

## Example

```tsx
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";

const tags = Array.from({ length: 40 }, (_, i) => `v1.2.0-beta.${40 - i}`);

export default function ScrollAreaDemo() {
  return (
    <ScrollArea seed="scroll-demo" className="h-72 w-56">
      <div className="p-4">
        <h4 className="mb-3 text-lg font-bold">Tags</h4>
        {tags.map((tag) => (
          <div key={tag}>
            <div className="py-1.5 text-base text-ink-2">{tag}</div>
            <Separator />
          </div>
        ))}
      </div>
    </ScrollArea>
  );
}
```

## Horizontal

A row of pictures that scrolls sideways.

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

const works = ["Spiral", "Waves", "Corner", "Star", "Slash", "Loops", "Zigzag", "Ring", "Tick", "Cross"];

export default function ScrollAreaHorizontal() {
  return (
    <ScrollArea seed="scroll-h" className="w-full max-w-md whitespace-nowrap">
      <div className="flex w-max gap-4 p-4">
        {works.map((work, i) => (
          <figure key={work} className="shrink-0">
            <div className="grid h-28 w-36 place-items-center text-ink-3 outline outline-1 outline-ink-4/60" style={{ rotate: `${(i % 3) - 1}deg` }}>
              {i + 1}
            </div>
            <figcaption className="pt-2 text-sm text-ink-3">{work}</figcaption>
          </figure>
        ))}
      </div>
    </ScrollArea>
  );
}
```

## Both directions

Both scrollbars on content wider and taller than the area.

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

export default function ScrollAreaBoth() {
  return (
    <ScrollArea seed="scroll-both" className="h-56 w-full max-w-sm">
      <div className="grid w-[640px] grid-cols-8 gap-2 p-3">
        {Array.from({ length: 96 }, (_, i) => (
          <div key={i} className="grid h-12 place-items-center text-sm text-ink-3 outline outline-1 outline-ink-4/40">
            {i + 1}
          </div>
        ))}
      </div>
    </ScrollArea>
  );
}
```

## Pen settings

- `weight`: `number` (default `1`). Line weight multiplier. Also settable in CSS as --ink-weight.
- `speed`: `number` (default `1`). Drawing speed multiplier. Also settable in CSS as --ink-speed.
