Scroll Area
LayoutContains overflowing content in a bounded viewport with styled scrollbars.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/scroll-area.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/scroll-area.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing scroll area
Set a height or width constraint so the viewport can scroll within its surrounding layout.
Add a horizontal ScrollBar when wide content needs horizontal scrolling.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
ScrollAreaProps
| Prop | Type | Required |
|---|---|---|
variant | "default" | "ink" | "plain" | null | undefined | No |
viewportClassName | string | No |
viewportPropsNative viewport attributes, including a ref, scroll listener or accessible name. | React.ComponentProps<typeof Primitive.Viewport> | No |
viewportWrapperCompose a primitive around the actual scrolling element, preserving its ref. | (viewport: React.ReactElement) => React.ReactNode | No |
ScrollAreaListProps
| Prop | Type | Required |
|---|---|---|
variant | "default" | "ink" | "plain" | null | undefined | No |
viewportClassName | string | No |
viewportPropsNative viewport attributes, including a ref, scroll listener or accessible name. | React.ComponentProps<typeof Primitive.Viewport> | No |
viewportWrapperCompose a primitive around the actual scrolling element, preserving its ref. | (viewport: React.ReactElement) => React.ReactNode | No |
maxHeight | React.CSSProperties["maxHeight"] | No |
ScrollBarProps
Accepts the native or primitive props declared by its exported TypeScript type.
PageScrollBarProps
Accepts the native or primitive props declared by its exported TypeScript type.
Accessibility
Keep scrolling content keyboard-reachable and give an independently scrollable region a useful name when it needs one.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.