Scroll Area
A region that scrolls inside a set size, with scrollbars that match the system.
The browser still does the scrolling, so the wheel, touch, the keyboard and find in page work as
usual; only the scrollbars are drawn by the system. Give it a size, and an aria-label to make it
a named region screen readers can jump to.
Sideways
Set orientation="horizontal" to scroll sideways, and type="auto" to keep the scrollbar in view
so the row reads as one that scrolls. orientation="both" scrolls either way.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | Nothing else in the system. |
|---|---|
| Used by | ConversationblockDialogMenuNav SheetblockPopoverSelectform itemSheetSidebarTableWorkspaceblock |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
ScrollArea
A region that scrolls inside a set size, with scrollbars that match the system. The browser still scrolls it, so the wheel, touch, keyboard and find in page all work. Give it a height (or width, to scroll sideways).
- aria-labelours
Names the scrolling region, which makes it a landmark screen readers can jump to.
Type string
- orientationours
Which ways the content scrolls. A horizontal scroll area lets its content grow as wide as it needs.
Type "both" | "horizontal" | "vertical" · Default vertical
- className
Type string | ((state: NoInfer<ScrollAreaState>) => string)
- controller
Drives it from anywhere. Create one with
createScrollAreaController().Type { scrollToEnd: (options?: ScrollAreaScrollOptions) => void; scrollToStart: (options?: ScrollAreaScrollOptions) => void; isAtEnd: () => boolean; isAtStart: () => boolean; isSticking: () => boolean; }
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- render
Type RenderProp<NoInfer<ScrollAreaState>>
- scrollHideDelay
How long scrollbars stay after they stop being needed, in ms, with "scroll" and "hover".
Type number · Default 600
- stickToEnd
Keeps the end in view while the content grows, like a chat or streamed output: it starts at the bottom and stays there. Scrolling toward the top lets go, and scrolling back to the bottom sticks again.
Type boolean · Default false
- style
Type CSSProperties | ((state: NoInfer<ScrollAreaState>) => CSSProperties)
- type
When the scrollbars show: "auto" whenever the content overflows, "always" even when it doesn't, "scroll" while scrolling, and "hover" while scrolling or while the pointer is over the scroll area. Each scrollbar has
data-visiblewhile it should show; style that.Type ScrollAreaType · Default "hover"
ScrollBar
One axis's scrollbar: shown while the pointer is over the area or it scrolls. ScrollArea adds its own.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: ScrollAreaScrollbarState) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: ScrollAreaScrollbarState) => string)
- orientation
The axis the scrollbar scrolls.
Type "horizontal" | "vertical" · Default "vertical"
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<ScrollAreaScrollbarState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: ScrollAreaScrollbarState) => CSSProperties)