Scroll Area
The scrollbar fades in and its thumb springs thicker when you reach for it.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/scroll-areaThis adds components/keyframery/scroll-area.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "@/components/keyframery/scroll-area"
export default function Usage() {
return (
<ScrollArea className="h-48">
<ScrollAreaViewport>
<ScrollAreaContent>{/* Long content */}</ScrollAreaContent>
</ScrollAreaViewport>
<ScrollAreaScrollbar>
<ScrollAreaThumb />
</ScrollAreaScrollbar>
</ScrollArea>
)
}Anatomy
How the parts fit together:
ScrollArea
├── ScrollAreaViewport
│ └── ScrollAreaContent
└── ScrollAreaScrollbar
└── ScrollAreaThumbExamples
Basic
Native scrolling with a slim scrollbar that shows while you scroll or hover.
Sideways
Add a horizontal scrollbar for wide content, like a row of photos.
Stick to the end
stickToEnd keeps a chat or a log at the newest line as it grows, unless you scroll up. ScrollAreaScrollToEnd brings you back.
Motion
| Move | What you see |
|---|---|
| Fade | The scrollbar fades in when you scroll. |
| Spring | The thumb springs thicker when you reach for it. |
Timing and springiness follow the motion style you set. To change how fast this scroll area moves, pass speed:
<ScrollArea speed="fast">
…
</ScrollArea>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--scroll-area-thumb | Thumb pigment (30%, 45% hover, 60% drag) | --foreground |
--scroll-area-key | Jump button surface | --background, --accent in dark |
--scroll-area-ink | Jump button text | --foreground |
--scroll-area-focus | Viewport focus ring | --ring |
--scroll-area-thickness | Full thumb thickness | 0.5rem |
--scroll-area-scrollbar-size | Scrollbar hit area | 0.875rem |
--scroll-area-fade | Maximum edge fade | 24px |
--scroll-area-radius | Thumb and jump button corners | 9999px |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK scroll area reference.
ScrollArea
Renders a <div>, and takes its props too.
Prop
Type
ScrollAreaScrollbar
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
ScrollAreaViewport: a<div>ScrollAreaContent: a<div>ScrollAreaThumb: a<div>ScrollAreaCorner: a<div>ScrollAreaScrollToEnd: a<button>
Keyboard
| Key | What it does |
|---|---|
| ↓ ↑ | Scrolls, once the area has focus. |
| Page Down | Scrolls a page. |
| Home | Scrolls to the start. |
| End | Scrolls to the end. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's scroll area with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/scroll-area"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/scroll-area"Questions
How does the animated Scroll Area for UI SDK move?
Fade: The scrollbar fades in when you scroll. Spring: The thumb springs thicker when you reach for it.
Do I need Motion or Framer Motion for the animated Scroll Area?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/scroll-area instead. It has the same parts and props as @ui-sdk/react/scroll-area and adds motion only.
What happens to the Scroll Area when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.