Scroll Area
A native scroll container with stylable scrollbars. The required structure is `Root > Viewport > Content` — the `Scrollbar`s go **outside** the `Viewport`, as siblings within `Root`.
import { ScrollArea } from "gnome-ui/scroll-area"; export function ScrollAreaVertical() { return ( <ScrollArea.Root className="h-48 w-80 rounded-xl border border-border bg-card overflow-hidden"> <ScrollArea.Viewport className="h-full w-full"> <ScrollArea.Content className="px-4 py-3"> <p>Long content here...</p> </ScrollArea.Content> </ScrollArea.Viewport> {/* Scrollbar goes outside the Viewport */} <ScrollArea.Scrollbar orientation="vertical"> <ScrollArea.Thumb /> </ScrollArea.Scrollbar> </ScrollArea.Root> ); }
Code Block
Ideal for code blocks with horizontal scroll. min-w-max on Content prevents text wrapping.
ScrollAreaContent
A container for the content of the scroll area.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
ScrollAreaCorner
A small rectangular area that appears at the intersection of horizontal and vertical scrollbars.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
ScrollAreaRoot
Groups all parts of the scroll area.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
| overflowEdgeThreshold | number | Partial<{ xStart: number; xEnd: number; yStart: number; yEnd: number; }> | 0 | The threshold in pixels that must be passed before the overflow edge attributes are applied. Accepts a single number for all edges or an object to configure them individually. |
ScrollAreaScrollbar
A vertical or horizontal scrollbar for the scroll area.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
| orientation | "horizontal" | "vertical" | 'vertical' | Whether the scrollbar controls vertical or horizontal scroll. |
| keepMounted | boolean | false | Whether to keep the HTML element in the DOM when the viewport isn’t scrollable. |
ScrollAreaThumb
The draggable part of the scrollbar that indicates the current scroll position.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
ScrollAreaViewport
The actual scrollable container of the scroll area.
Renders a <div> element.
Documentation: Base UI Scroll Area
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | (...) => string) | — | CSS class applied to the element, or a function that returns a class based on the component’s state. |
| render | ReactElement> | ComponentRenderFn | — | Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |