Scroll area
A scrollable region with thin, themed scrollbars.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- Built on radix-ui/ScrollArea
- The viewport is focusable (tabindex 0) so keyboard users can scroll it; give it an aria-label when it holds standalone content.
- Native scrolling semantics are preserved.
- Styles in one file:
scroll-area.css
Import
import '@monoline/css';
import {ScrollArea} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add scroll-area
It needs radix-ui; install it if your project does not have it:
npm install radix-ui
Usage
import {ScrollArea} from '@monoline/react';
<ScrollArea
style={{height: '160px', width: '320px', border: '1px solid var(--rule)'}}
viewportProps={{'aria-label': 'Release notes'}}
>
<div style={{padding: 'var(--s3)'}}>
{Array.from({length: 20}, (_, i) => <p key={i}>Release note {i + 1}</p>)}
</div>
</ScrollArea>
Examples
Vertical
Props
ScrollAreaProps
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "both" | 'vertical' | Which scrollbars to render. |
viewportProps | Omit<Radix.ScrollAreaViewportProps & RefAttributes<HTMLDivElement>, "ref"> | – | Passed to the focusable viewport, e.g. a name for the region. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[data-orientation="horizontal"] | scroll-area.css |
[data-orientation="vertical"] | scroll-area.css |
CSS classes
| Class | Stylesheet |
|---|---|
.scroll-area | scroll-area.css |
.scroll-bar | scroll-area.css |
.scroll-thumb | scroll-area.css |
.scroll-viewport | scroll-area.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.scroll-area {
border-color: var(--accent);
}
.scroll-area[data-orientation="horizontal"] {
background: var(--wash);
}
Accessibility
- The viewport is focusable (tabindex 0) so keyboard users can scroll it; give it an aria-label when it holds standalone content.
- Native scrolling semantics are preserved.