Scrollbar
Add scrollbar to scrollable content.
Scrollbar
Usage
import { Scrollbar } from "@bedform/ui/scrollbar";
export function WorldList() {
return (
<Scrollbar aria-label="World list" style={{ maxHeight: "12rem" }}>
<div>World 1</div>
<div>World 2</div>
<div>World 3</div>
</Scrollbar>
);
}Native scrolling
Scrollbar renders a div that is a real overflow container. Wheel scrolling, touch inertia, and scroll position remain attached to that native container. Its controller manages tabindex from actual overflow, normalizes keyboard scrolling, and adds the Firefox visual fallback.
Chromium and Safari use ::-webkit-scrollbar* to reproduce the layered pixel thumb. Firefox does not expose the required thumb and track pseudo-elements, so the controller hides its native scrollbar and overlays the same track and thumb layers while keeping the real element as the scroll container. The overlay mirrors native scroll position and pointer dragging.
To style another element's scrollbar, such as a list rendered by another library, give it the ore-scrollbar class. The controller starts once any Scrollbar has been imported; without it, Firefox falls back to scrollbar-color and its native scrollbar.
CSS variables
| Variable | Purpose |
|---|---|
--ore-scrollbar-unit | Base size unit |
--ore-scrollbar-size | Vertical scrollbar width |
--ore-scrollbar-horizontal-size | Horizontal scrollbar height |
--ore-scrollbar-track-size | Track line thickness |
--ore-scrollbar-thumb-min-size | Minimum thumb length |
--ore-scrollbar-track | Track color |
--ore-scrollbar-thumb-border | Thumb border color |
--ore-scrollbar-thumb-highlight | Thumb highlight color |
--ore-scrollbar-thumb-background | Thumb background color |
--ore-scrollbar-thumb-shadow | Thumb shadow color |
Accessibility
When the controller is imported, an overflowing region without an authored tabindex receives tabindex="0"; a region without overflow receives tabindex="-1". An explicit tabindex, including -1, is never overwritten. Arrow keys, Page Up/Down, Home, and End are normalized only when the scroll region itself has focus, so controls inside it retain their native keyboard behavior. Give the region an accessible name with aria-label or aria-labelledby.