Icons
ui.system_iconsprovider 无关的语义图标角色、尺寸与着色。Provider-neutral semantic icon roles, sizes and tints.
BEHAVIOR CONTRACT
组件只依赖 system_icons 角色;替换图标 provider 时组件 API 不变。Components depend on system_icons roles only; swapping the icon provider changes no component API.
RECORDED INTERACTION
虚拟鼠标扫过语义图标、尺寸与 tint。The virtual cursor sweeps roles, sizes and tints.
pub fn buildIconGallery(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 12);
try c.appendChild(a, try label(cx, "System icon contract (provider-neutral subset)"));
// wrap 成多行网格:每行 6 个。
var current_row = try row(cx, 8);
var in_row: usize = 0;
inline for (GALLERY_ICONS) |spec| {
if (in_row == 6) {
try c.appendChild(a, current_row);
current_row = try row(cx, 8);
in_row = 0;
}
try current_row.appendChild(a, try iconCell(scope, cx, spec.asset, spec.name));
in_row += 1;
}
try c.appendChild(a, current_row);
// 尺寸 + tint 演示行
try c.appendChild(a, try label(cx, "Sizes & tints"));
const demo = try row(cx, 16);
inline for (.{ 16, 24, 32, 48 }) |sz| {
try demo.appendChild(a, try ui.iconTint(cx, ui.system_icons.alert, light.color.fg_secondary, .{
.width = .{ .px = @as(f32, sz) },
.height = .{ .px = @as(f32, sz) },
}));
}
try demo.appendChild(a, try ui.iconTint(cx, ui.system_icons.heart, .{ .r = 220, .g = 40, .b = 60, .a = 255 }, .{
.width = .{ .px = 32 },
.height = .{ .px = 32 },
}));
try c.appendChild(a, demo);
return c;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。The story's verbatim source from the Storybook (zenit 5f9add5+wip 2026-09-30). W is ui.widgets; col / row / label are small Storybook layout helpers.