Divider
ui.widgets.DividerHorizontale, vertikale und beschriftete Trenner.
BEHAVIOR CONTRACT
Richtung, Label-Position, Farbe und Abstand stammen aus den Theme-Tokens.
RECORDED INTERACTION
Zeigt solid / dashed, ein OR-Label und vertikale Trenner.
// ── 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;
}Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). W steht für ui.widgets; col / row / label sind kleine Layout-Helfer des Storybooks.
DividerProps
ui.widgets.Dividerfn Divider(props: DividerProps) DividerBuilderFeld
Typ
Standard
Beschreibung
orientationDividerOrientation.horizontal.vertical.horizontal方向
variantDividerVariant.solid.dashed.dotted.solid样式变体
spacingDividerSpacing.none.sm.md.lg.md间距
label_text?[]const u8null标签文本
label_positionLabelPosition.left.center.right.center标签位置
color?Colornull颜色
thicknessf321粗细
dash_lengthf328dash 的实线段长度
dash_gapf328dash 的间距
*Node
ui.widgets.Dividermount gibt *Node direkt zurück – hängen Sie es an einen Elternknoten an.