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>
);
}import { ScrollArea } from "@senvenli/react/layout";Examples
Horizontal
Wide content scrolls sideways inside its column; the parent sets the width.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.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
- Rows need a sticky header, paging and their own scrolling. Data table
- Long side content belongs in a panel opened on demand. Drawer
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| 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-labelthat names the region.
API reference
ScrollArea
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | React.ReactNode | – | |
aria-labelRequired | string | – | Names the region; screen readers announce it when focus enters. |
maxHeight | string | number | – | The region's height limit ("320px", 320, "60vh"); for horizontal areas, set the width on the parent. |
fill | boolean | false | 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 ( |
orientation | "both" | "horizontal" | "vertical" | "vertical" |
childrenRequiredReact.ReactNodearia-labelRequiredstringNames the region; screen readers announce it when focus enters.
maxHeightstring | numberThe region's height limit ("320px", 320, "60vh"); for horizontal areas, set the width on the parent.
fillbooleanDefaultfalseFills 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-0on a flex or grid child). LeavemaxHeightout when filling.orientation"both" | "horizontal" | "vertical"Default"vertical"