Alert
ui.widgets.Alert页面内持久反馈。Persistent in-page feedback.
BEHAVIOR CONTRACT
info / success / warning / error 语义色、标题和无标题消息保持一致布局。info / success / warning / error, with or without a title, keep one layout.
RECORDED INTERACTION
录像展示四种语义级别。Shows all four severity levels.
// ── Alert ──
pub fn buildAlert(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 12);
// 全 4 变体,且都带 closable(× 关闭按钮)
try c.appendChild(a, try W.Alert(.{ .variant = .info, .title = "Info", .message = "Informational message.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .success, .title = "Success", .message = "It worked.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .warning, .title = "Warning", .message = "Be careful.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .@"error", .title = "Error", .message = "Something broke.", .closable = true }).mount(scope, cx));
// 无标题(仅 message)
try c.appendChild(a, try W.Alert(.{ .variant = .info, .message = "Title-less alert with just a message." }).mount(scope, cx));
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.