ValyroUI Русская версия

Scroll Area

Scroll area: themed bars, soft edge fades, stick to bottom for chats. Free, MIT · Navigation and layout › Structure

A scroll container with the kit's thin overlay scrollbars, soft fades (or shadows) at the edges that grow with the hidden distance, and a follow mode for chats and logs that keeps the end in view while content streams in.

Installation

npx valyro-cli@latest add scroll-area
npx shadcn@latest add https://valyro.xyz/r/scroll-area.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { ScrollArea } from 'valyro-ui';

Props

PropTypeDefault
childrenReactNodeContent, or the compound parts ScrollArea.Viewport (with ScrollArea.Content), .Scrollbar, .Corner and .ScrollButton.
orientation'vertical' | 'horizontal' | 'both''vertical'Axes that scroll. Default vertical.
scrollbars'overlay' | 'native' | 'hidden''overlay'overlay: the kit's thin bars over the content; native: the browser's bars in theme colours; hidden: none (wheel, touch and keys still scroll). Default overlay.
visibility'hover' | 'scroll' | 'auto' | 'always''hover'When overlay bars show: while the pointer is over the area, while scrolling, whenever it overflows, or always. Default hover.
hideDelaynumber600Ms before overlay bars hide after the pointer leaves or scrolling stops. Default 600.
edges'fade' | 'shadow' | 'none''fade'Hint at content hidden past an edge: a soft mask, an inset shadow, or nothing. Default fade.
edgeSizenumberDepth of the fade or shadow, px. Default --ui-scroll-area-edge-size (24px).
followbooleanKeep the end in view while content grows (chats, logs): any scroll back releases it, reaching the end picks it up again. Controlled: pair with onFollowChange. Passing this or defaultFollow turns follow mode on.
defaultFollowbooleanInitial follow when uncontrolled.
onFollowChange(follow: boolean) => voidCalled with the new follow when it changes.
thresholdnumber32Distance from the end, px, that counts as being at it. Default 32.
initialScroll'start' | 'end'Where it opens; end is applied before the first paint (no flash of the top). Default start, or end while following.
onEdgeReached(edge: ScrollAreaEdge) => voidCalled once each time an edge is reached (load more, older messages). start / end are the inline sides and mirror in RTL.
scrollButtonbooleanFloating "scroll to end" button while the end is out of view. Default: on in follow mode.
labelstringAccessible name of the scroll region, applied (with role="region") only while it overflows.
viewportRefRef<HTMLDivElement>Ref of the scrolling element (the root gets ref, className, style, data-* and aria-*).
viewportPropsComponentPropsWithRef<'div'>Props of the scrolling element.
labelsPartial<ScrollAreaLabels>Overrides for the built-in English text; keys left out keep their defaults.

Compound parts

ScrollArea.Viewport (ScrollAreaViewport), ScrollArea.Content (ScrollAreaContent), ScrollArea.Scrollbar (ScrollAreaScrollbar), ScrollArea.Thumb (ScrollAreaThumb), ScrollArea.Corner (ScrollAreaCorner), ScrollArea.ScrollButton (ScrollAreaScrollButton)

Related components

Previous: Resizable Panels · Next: Breadcrumbs · All Navigation and layout