# Scroll

> A native scroll container with vertical, horizontal or two-axis scrolling.

- Category: [Window & layout](https://tarve.dev/docs.md#layout)
- Import: `import { Scroll } from "@tarve/core";`
- Props type: `ScrollProps`
- Source: [packages/core/src/components/scroll.ts:18](https://github.com/omarcosr/tarve/blob/main/packages/core/src/components/scroll.ts#L18)

## Usage

```tsx title="Scroll.tsx"
import { Scroll, Text } from "@tarve/core";

<Scroll
  gap={8}
  padding={12}
  style={{ height: 240 }}
  onScroll={(offset) => console.log("scrolled to", offset)}
>
  {Array.from({ length: 50 }, (_, index) => (
    <Text key={index}>Row {index + 1}</Text>
  ))}
</Scroll>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `followTail` | `boolean` | — | Stick to the end: while the area is at its end (or new), growing content keeps it there (a chat, a log). Scrolling away stops it; scrolling back to the end resumes it. |
| `onScroll` | `(offset: number, max: number, info: ScrollInfo) => void` | — |  |
| `onScrollPosition` | `(position: ScrollPosition) => void` | — |  |
| `orientation` | `ScrollOrientation` | `"vertical"` |  |
| `speed` | `number` | `1` |  |

### Inherited from `ViewProps`

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `align` | `Style["align"]` | — |  |
| `autoFocus` | `boolean` | — | Focus this control when it first appears (HTML `autofocus`); interactive views only (Pressable). |
| `children` | `BindableChild` | — |  |
| `dismissOnOutside` | `boolean` | — | A press outside the box fires `onOutsideClick` instead of reaching what is under it (light dismiss). Works on portals and in-flow boxes; an open portal wins. |
| `dragRegion` | `boolean` | — |  |
| `flex` | `number \| string` | — | CSS `flex`: `1` is `1 1 0`; strings take any CSS value, e.g. `"1 1 176px"`. |
| `focusable` | `boolean` | — |  |
| `gap` | `number` | — |  |
| `justify` | `Style["justify"]` | — |  |
| `onOutsideClick` | `() => void` | — | With `dismissOnOutside`: a press (or right click) outside the box. |
| `padding` | `Style["padding"]` | — |  |
| `portal` | `boolean` | — |  |
| `style` | `Reactive<Style>` | — | Values may be signals: setting one restyles this box without a render. |
| `windowAction` | `"minimize" \| "toggleMaximize" \| "toggleFullscreen" \| "close"` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `class`, `className`, `dropTarget`, `fileDropTarget`, `highlight`, `id`, `key`, `motionFrom`, `onDragEnter`, `onDragLeave`, `onDrop`, `onFileDragEnter`, `onFileDragLeave`, `onFileDrop`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`.

## Types

```ts title="BindableChild"
type BindableChild = Child | Signal<unknown> | BindableChild[];
```

```ts title="Reactive"
type Reactive<S> = { [K in keyof S]: S[K] | Signal<Exclude<S[K], undefined>> };
```

```ts title="ScrollInfo"
interface ScrollInfo { source: ScrollSource }
```

```ts title="ScrollOrientation"
type ScrollOrientation = "vertical" | "horizontal" | "both";
```

```ts title="ScrollPosition"
interface ScrollPosition { x: number; y: number; maxX: number; maxY: number; source: ScrollSource }
```

Previous: [Column](https://tarve.dev/docs/components/Column.md) · Next: [ScrollArea](https://tarve.dev/docs/components/ScrollArea.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Scroll · Index for agents: https://tarve.dev/llms.txt
