Keyframery

Scroll Area

The scrollbar fades in and its thumb springs thicker when you reach for it.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/scroll-area

This 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
    └── ScrollAreaThumb

Examples

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

MoveWhat you see
FadeThe scrollbar fades in when you scroll.
SpringThe 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.

VariableWhat it changesDefault
--scroll-area-thumbThumb pigment (30%, 45% hover, 60% drag)--foreground
--scroll-area-keyJump button surface--background, --accent in dark
--scroll-area-inkJump button text--foreground
--scroll-area-focusViewport focus ring--ring
--scroll-area-thicknessFull thumb thickness0.5rem
--scroll-area-scrollbar-sizeScrollbar hit area0.875rem
--scroll-area-fadeMaximum edge fade24px
--scroll-area-radiusThumb and jump button corners9999px

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

KeyWhat it does
↓ ↑Scrolls, once the area has focus.
Page DownScrolls a page.
HomeScrolls to the start.
EndScrolls 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.

All components

On this page