Scroll Area
Scroll container with a token-styled scrollbar.
Import
Section titled “Import”import { ScrollArea, ScrollAreaViewport, ScrollAreaScrollbar, ScrollAreaThumb,} from "@pelagornis/page/components";Example
Section titled “Example”The preview above renders this file. Copy it into src/components/ to start from it.
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> );}Use in MDX
Section titled “Use in MDX”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.
---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.
Use in Markdoc
Section titled “Use in Markdoc”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.
---import ScrollAreaExample from "../ScrollAreaExample";---
<ScrollAreaExample client:load />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, }, },});{% scroll-area-example /%}Variants
Section titled “Variants”Values the component accepts for each variant prop.
| Prop | Values |
|---|---|
type | hover always |
Anatomy
Section titled “Anatomy”Parts of the component and the data-refineui role each one renders.
| Part | Role |
|---|---|
root | scroll-area |
scrollbar | scroll-area-scrollbar |
thumb | scroll-area-thumb |
track | scroll-area-track |
viewport | scroll-area-viewport |
States
Section titled “States”States the component styles. Component states are exposed as data attributes.
| Kind | States |
|---|---|
| data-state | visible hidden |
Reference
Section titled “Reference”- RefineUI · Scroll Area for design guidance and token detail.
- Use in MDX and Use in Markdoc for the general rules.