components/alert
データ表示 · 22 / 64

Alert

ui.widgets.Alert

ページ内に留まるフィードバック。

BEHAVIOR CONTRACT

info / success / warning / error は、タイトルの有無にかかわらず同じレイアウトを保ちます。

RECORDED INTERACTION

4 つの重要度レベルを示します。

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 でソースを見るexamples/storybook/stories.zig:664

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