components/scrollarea
Layout · 50 / 64

ScrollArea

ui.widgets.mountScrollArea

Custom-drawn scrolling, scrollbars and programmatic positioning.

BEHAVIOR CONTRACT

Wheel / trackpad, clamping, momentum, scrollbar, scrollIntoView and pixel alignment share state.

RECORDED INTERACTION

The harness scrolls the content and records the thumb moving.

examples/storybook/stories.zig:2986
// ── ScrollArea ──
pub fn buildScrollArea(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const sa = try W.mountScrollArea(.{ .width = 320, .height = 320, .direction = .vertical }, scope, cx);
    var i: usize = 0;
    while (i < 40) : (i += 1) {
        var buf: [32]u8 = undefined;
        const txt = try std.fmt.bufPrint(&buf, "Scrollable line {d}", .{i});
        try sa.content.appendChild(a, try ui.text(cx, txt, .{ .font_size = 13, .color = light.color.fg_primary }));
    }
    return sa.container;
}
View source on GitHubexamples/storybook/stories.zig:2986

The story's verbatim source from the Storybook (zenit 4c50245 2026-10-01). W is ui.widgets; col / row / label are small Storybook layout helpers.

zenit · Dual-licensedFree for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.Contact the author: zongyi.xzy#gmail.com (replace # with @)zenit 4c50245 2026-10-01