Install
Pull Scroll Area from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { ScrollArea } from "@brika/clay";import { ScrollArea } from "@brika/clay/components/scroll-area";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { ScrollArea } from '@brika/clay/components/scroll-area';
/** Vertical scroll area constraining a long list to a fixed height. */
export default function ScrollAreaDefaultDemo() {
const rows = Array.from({ length: 20 }, (_, i) => `Component ${i + 1}`);
return (
<ScrollArea className="h-72 w-64 rounded-md border border-clay-hairline">
<ul className="divide-y divide-clay-hairline">
{rows.map((row) => (
<li key={row} className="px-4 py-2 text-clay-default text-sm">
{row}
</li>
))}
</ul>
</ScrollArea>
);
}Scroll Area, every way
Accessibility
- The scrollable region carries
role="region", pair witharia-labelfor context. - Custom scrollbars do not affect keyboard scrolling, arrow keys and Page Up/Down work normally.
- Horizontal scroll areas should be announced; users may not expect horizontal scrolling.
Theme tokens
Every CSS variable Scroll Area reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Scroll Area
without touching component code.
Scroll Area tokens
3 tokens--scroll-area-thumb-colorcolorvar(--border)components.scrollArea.thumbColorBackground color of the draggable scrollbar thumb.
--scroll-area-track-colorcolortransparentcomponents.scrollArea.trackColorBorder color drawn along the scrollbar track edge that meets the viewport (left edge for vertical, top edge for horizontal). Defaults to transparent so the track blends into the surface behind it.
--scroll-area-viewport-ringcolorvar(--ring)components.scrollArea.viewportRingFocus ring color drawn around the scroll viewport when keyboard-focused; rendered at 50% opacity.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.scrollArea, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"scrollArea": {
"thumbColor": "var(--border)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-scroll-area-…) — see the
chips on each token row.
API reference
Props specific to Scroll Area. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<ScrollArea />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ScrollBar />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.