components/divider
레이아웃과 대용량 데이터 · 45 / 64

Divider

ui.widgets.Divider

가로, 세로, 라벨이 있는 구분선.

BEHAVIOR CONTRACT

방향, 라벨 위치, 색상, 간격은 테마 token에서 가져옵니다.

RECORDED INTERACTION

solid / dashed, OR 라벨, 세로 구분선을 보여 줍니다.

examples/storybook/stories.zig:523
// ── Divider ──
pub fn buildDivider(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 16);

    // ── 样式:solid / dashed / dotted ──
    try c.appendChild(a, try label(cx, "Styles (solid / dashed / dotted)"));
    inline for (.{ W.divider.DividerVariant.solid, .dashed, .dotted }) |variant| {
        try c.appendChild(a, try W.Divider(.{ .orientation = .horizontal, .variant = variant }).mount(scope, cx));
    }

    // ── 带 label,三种位置 ──
    try c.appendChild(a, try label(cx, "Labeled (left / center / right)"));
    try c.appendChild(a, try W.Divider(.{ .label_text = "LEFT", .label_position = .left }).mount(scope, cx));
    try c.appendChild(a, try W.Divider(.{ .label_text = "OR", .label_position = .center }).mount(scope, cx));
    try c.appendChild(a, try W.Divider(.{ .label_text = "RIGHT", .label_position = .right }).mount(scope, cx));

    // ── 垂直方向 ──
    try c.appendChild(a, try label(cx, "Vertical"));
    const vrow = try ui.box(cx, .{ .direction = .row, .gap = 12, .align_items = .center, .height = .{ .px = 32 } }, .{});
    try vrow.appendChild(a, try ui.text(cx, "Left", .{ .font_size = 13, .color = light.color.fg_primary }));
    try vrow.appendChild(a, try W.Divider(.{ .orientation = .vertical }).mount(scope, cx));
    try vrow.appendChild(a, try ui.text(cx, "Middle", .{ .font_size = 13, .color = light.color.fg_primary }));
    try vrow.appendChild(a, try W.Divider(.{ .orientation = .vertical }).mount(scope, cx));
    try vrow.appendChild(a, try ui.text(cx, "Right", .{ .font_size = 13, .color = light.color.fg_primary }));
    try c.appendChild(a, vrow);
    return c;
}
GitHub에서 소스 보기examples/storybook/stories.zig:523

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