v0.1.0-alpha
官网Home
components/alert
数据展示Display · 22 / 64

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.

examples/storybook/stories.zig:664
// ── 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;
}
在 GitHub 查看源码View source on GitHubexamples/storybook/stories.zig:664

这是 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.

zenit · 双授权Dual-licensed开源项目可按 GPL-3.0-only 免费使用;闭源或商业产品需要商业授权。Free for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.可联系作者:Contact the author: zongyi.xzy#gmail.com(# 换成 @) (replace # with @)zenit 5f9add5+wip 2026-09-30