Skip to content
Page

Scroll Area

Scroll container with a token-styled scrollbar.

v2.20.0v2.19.0v2.18.0v2.17.0v2.16.0v2.15.0v2.14.0v2.13.0v2.12.0v2.11.0v2.10.0v2.9.0v2.8.0v2.7.0v2.6.0v2.5.0v2.4.0v2.3.0v2.2.0v2.1.0
import {
ScrollArea,
ScrollAreaViewport,
ScrollAreaScrollbar,
ScrollAreaThumb,
} from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/ScrollAreaExample.tsx
import {
ScrollArea,
ScrollAreaScrollbar,
ScrollAreaThumb,
ScrollAreaViewport,
Stack,
Text,
} from "@pelagornis/page/components";
const releases = Array.from({ length: 20 }, (_, index) => `v2.${20 - index}.0`);
export default function ScrollAreaDemo() {
return (
<ScrollArea type="hover" className="h-48 w-full max-w-xs">
<ScrollAreaViewport>
<Stack gap="sizeXSmall">
{releases.map((release) => (
<Text key={release} variant="bodyMd">
{release}
</Text>
))}
</Stack>
</ScrollAreaViewport>
<ScrollAreaScrollbar orientation="vertical">
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>
);
}

Scroll Area is composed from parts that share React state. Children written in MDX are rendered as separate islands, so the parts can’t reach each other. Put the composition in a .tsx file, like the example above, and import that file instead.

src/content/docs/example.mdx
---
title: Example
---
import ScrollAreaExample from "../../components/ScrollAreaExample";
<ScrollAreaExample client:load />

client:load hydrates the island on page load. Use client:visible for content far down the page.

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/ScrollAreaExample.astro
---
import ScrollAreaExample from "../ScrollAreaExample";
---
<ScrollAreaExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"scroll-area-example": {
render: component("./src/components/markdoc/ScrollAreaExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% scroll-area-example /%}

Values the component accepts for each variant prop.

PropValues
typehover always

Parts of the component and the data-refineui role each one renders.

PartRole
rootscroll-area
scrollbarscroll-area-scrollbar
thumbscroll-area-thumb
trackscroll-area-track
viewportscroll-area-viewport

States the component styles. Component states are exposed as data attributes.

KindStates
data-statevisible hidden