# Scroll area

A region that scrolls inside a height limit with thin themed scrollbars, keyboard reachable.

- Family: layout
- Import: `import { ScrollArea } from "@senvenli/react/layout";`
- Page: https://design.senvenli.com/docs/components/scroll-area
- JSON: https://design.senvenli.com/docs/components/scroll-area.json

## Example: A long list in a short box

`maxHeight` caps the region; a shadow shows where content continues.

```tsx
import { Text } from "@senvenli/react/display";
import { ScrollArea } from "@senvenli/react/layout";
import { Stack } from "@senvenli/react/layout";

const ORDERS = Array.from({ length: 16 }, (_, index) => ({ id: 1042 - index, total: 120 + index * 35 }));

export default function Example() {
  return (
    <div className="max-w-sm">
      <ScrollArea aria-label="Recent orders" maxHeight={200}>
        <Stack space="space-150">
          {ORDERS.map((order) => (
            <Stack direction="horizontal" key={order.id} justify="between">
              <Text>Order #{order.id}</Text>
              <Text tone="subtle" isNumeric>
                ${order.total}.00
              </Text>
            </Stack>
          ))}
        </Stack>
      </ScrollArea>
    </div>
  );
}
```

## Examples

### Horizontal

Wide content scrolls sideways inside its column; the parent sets the width.

```tsx
import { Badge } from "@senvenli/react/display";
import { ScrollArea } from "@senvenli/react/layout";
import { Stack } from "@senvenli/react/layout";

const STAGES = ["Draft", "Submitted", "Under review", "Approved", "Scheduled", "In production", "Packed", "Shipped", "Delivered", "Closed"];

export default function Example() {
  return (
    <div className="max-w-sm">
      <ScrollArea aria-label="Order stages" orientation="horizontal">
        <Stack direction="horizontal" space="space-100" wrap={false} paddingBlock="space-100">
          {STAGES.map((stage) => (
            <Badge key={stage}>{stage}</Badge>
          ))}
        </Stack>
      </ScrollArea>
    </div>
  );
}
```

### Filling a pane

Between a fixed header and footer, the area takes the height that is left.

```tsx
import { Button } from "@senvenli/react/action";
import { Heading, Text } from "@senvenli/react/display";
import { ScrollArea } from "@senvenli/react/layout";
import { Stack } from "@senvenli/react/layout";

const NOTES = Array.from({ length: 12 }, (_, index) => `Note ${index + 1}: the customer asked about delivery times.`);

export default function Example() {
  return (
    // The parent gives the height; the area takes what the header and the footer leave.
    <div className="flex h-64 max-w-sm flex-col gap-ds-150">
      <Heading level={3} size="heading-small">
        Customer notes
      </Heading>
      <ScrollArea aria-label="Customer notes" fill>
        <Stack space="space-100">
          {NOTES.map((note) => (
            <Text key={note}>{note}</Text>
          ))}
        </Stack>
      </ScrollArea>
      <Button>Add note</Button>
    </div>
  );
}
```

## Guidelines

### When to use it

- A long list or pane must stay within a fixed height.

### Use something else when

- [data-table](https://design.senvenli.com/docs/components/data-table.md): Rows need a sticky header, paging and their own scrolling.
- [drawer](https://design.senvenli.com/docs/components/drawer.md): Long side content belongs in a panel opened on demand.

## Accessibility

Keyboard:

- Tab: Moves focus into the region so arrow keys scroll it.

Built in:

- The region is focusable and announced by its label.

You provide:

- An `aria-label` that names the region.

## API reference

### ScrollArea

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| children | `React.ReactNode` |  | yes |  |
| aria-label | `string` |  | yes | Names the region; screen readers announce it when focus enters. |
| maxHeight | `string \| number` |  | no | The region's height limit ("320px", 320, "60vh"); for horizontal areas, set the width on the parent. |
| fill | `boolean` | `false` | no | Fills the parent's height and scrolls inside it, for a pane in a flex column or a grid row that is given its height: a conversation's messages between its header and the reply box, a list beside it. The parent must give the area a definite height (`min-h-0` on a flex or grid child). Leave `maxHeight` out when filling. |
| orientation | `"both" \| "horizontal" \| "vertical"` | `"vertical"` | no |  |

### Tokens it reads

`--ds-border-bold`, `--ds-border-focused`, `--ds-shadow-overflow`
