Skip to main content

Scrollbar

Custom scrollbar with accessible controls.

Usage

<w-scrollbar>
<w-slot body>
<div>
<!-- Scrollable content -->
</div>
</w-slot>
<w-slot rail>
<div>
<w-slot knob><div></div></w-slot>
</div>
</w-slot>
</w-scrollbar>

Props

PropTypeDefaultDescription
orientation"vertical" | "horizontal""vertical"Scroll direction

Slots

SlotElementDescription
contentContainerScrollable content area
trackContainerScrollbar track
thumbElementDraggable thumb

Keyboard

KeyAction
ArrowDown / ArrowRightScroll forward
ArrowUp / ArrowLeftScroll backward
Page DownScroll page forward
Page UpScroll page backward
HomeScroll to start
EndScroll to end

Styling

The library sets overflow-x and overflow-y automatically based on [orientation]. You only need to size the host. Use the standard browser scrollbar styling APIs (scrollbar-width, scrollbar-color, ::-webkit-scrollbar) for visual treatment.

w-scrollbar {
scrollbar-width: thin;
scrollbar-color: #888 #f0f0f0;
}

w-scrollbar::-webkit-scrollbar {
width: 8px;
height: 8px;
}
w-scrollbar::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
SelectorTargets
w-scrollbar[orientation="horizontal"]Horizontal scroll only
w-scrollbar[orientation="vertical"]Vertical scroll only
w-scrollbar[orientation="both"]Both axes

Accessibility

  • role="scrollbar" with proper ARIA
  • Keyboard accessible
  • Thumb position reflects scroll state