---
title: "Composant Alert — zenit Zig UI"
description: "Retour persistant dans la page. info / success / warning / error, avec ou sans titre, gardent une même mise en page."
url: https://zenit.z.express/fr/components/alert
language: fr
alternate_en: https://zenit.z.express/components/alert.md
alternate_zh: https://zenit.z.express/zh/components/alert.md
alternate_es: https://zenit.z.express/es/components/alert.md
alternate_ja: https://zenit.z.express/ja/components/alert.md
alternate_ko: https://zenit.z.express/ko/components/alert.md
alternate_de: https://zenit.z.express/de/components/alert.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Alert

`ui.widgets.Alert`

Retour persistant dans la page.

[Video](https://zenit.z.express/media/stories/alert.mp4?v=b7df1ff242)

**BEHAVIOR CONTRACT**

info / success / warning / error, avec ou sans titre, gardent une même mise en page.

**RECORDED INTERACTION**

Montre les quatre niveaux de gravité.

`examples/storybook/stories.zig:664`

```zig
// ── 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;
}
```

[Voir le code sur GitHubexamples/storybook/stories.zig:664](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L664)

Le code source tel quel de la story dans le Storybook (zenit 5f9add5+wip 2026-09-30). `W` désigne `ui.widgets` ; `col` / `row` / `label` sont de petits helpers de mise en page du Storybook.

### AlertProps

`ui.widgets.Alert`

[src/ui/components/alert/mod.zig:40](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/alert/mod.zig#L40)

```zig
fn Alert(props: AlertProps) AlertBuilder
```

| Champ | Type | Défaut | Description |
| --- | --- | --- | --- |
| `variant` | `AlertVariant` `.info` `.success` `.warning` `.@"error"` | `.info` | — |
| `title` | `?[]const u8` | `null` | — |
| `message` | `[]const u8` | `""` | — |
| `closable` | `bool` | `false` | — |
| `on_close` | `?core.HandlerRef` | `null` | — |
| `close_icon_asset` | `?svg_assets.Asset` | `null` | — |

### \*Node

`ui.widgets.Alert`

mount renvoie directement `*Node` : ajoutez-le à un parent.
