components/scrollarea
レイアウトと大規模データ · 50 / 64

ScrollArea

ui.widgets.mountScrollArea

自前描画のスクロール、スクロールバー、プログラムからの位置指定。

BEHAVIOR CONTRACT

wheel / trackpad、clamp、momentum、scrollbar、scrollIntoView、ピクセル揃えが state を共有します。

RECORDED INTERACTION

harness がコンテンツ領域をスクロールし、thumb の移動を記録します。

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;
}
GitHub でソースを見るexamples/storybook/stories.zig:2986

Storybook にあるこの story のコードそのままです(zenit 5f9add5+wip 2026-09-30)。W は ui.widgets のことで、col / row / label は Storybook 内の小さなレイアウトヘルパーです。

zenit · デュアルライセンスオープンソースプロジェクトは GPL-3.0-only のもとで無料で使えます。クローズドソースや商用製品には商用ライセンスが必要です。作者への連絡先:zongyi.xzy#gmail.com(# を @ に置き換え)zenit 5f9add5+wip 2026-09-30