---
title: "Composant Rate — zenit Zig UI"
description: "Notes en étoiles ou sur un nombre borné d'éléments. count, value, taille et lecture seule ; l'aperçu au survol correspond à la valeur validée."
url: https://zenit.z.express/fr/components/rate
language: fr
alternate_en: https://zenit.z.express/components/rate.md
alternate_zh: https://zenit.z.express/zh/components/rate.md
alternate_es: https://zenit.z.express/es/components/rate.md
alternate_ja: https://zenit.z.express/ja/components/rate.md
alternate_ko: https://zenit.z.express/ko/components/rate.md
alternate_de: https://zenit.z.express/de/components/rate.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Rate

`ui.widgets.Rate`

Notes en étoiles ou sur un nombre borné d'éléments.

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

**BEHAVIOR CONTRACT**

count, value, taille et lecture seule ; l'aperçu au survol correspond à la valeur validée.

**RECORDED INTERACTION**

Montre 5 et 10 éléments, la lecture seule et trois tailles.

`examples/storybook/stories.zig:2393`

```zig
// ── Rate ──
pub fn buildRate(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 16);
    const r1 = try W.Rate(.{ .count = 5, .value = 3 }).mount(scope, cx);
    try c.appendChild(a, try label(cx, "value 3 / 5"));
    try c.appendChild(a, r1.wrapper);
    const r2 = try W.Rate(.{ .count = 5, .value = 4, .disabled = true }).mount(scope, cx);
    try c.appendChild(a, try label(cx, "readonly value 4"));
    try c.appendChild(a, r2.wrapper);

    // ── count 变体 ──
    const r3 = try W.Rate(.{ .count = 10, .value = 7 }).mount(scope, cx);
    try c.appendChild(a, try label(cx, "count 10, value 7"));
    try c.appendChild(a, r3.wrapper);

    // ── size 变体 ──
    try c.appendChild(a, try label(cx, "Sizes (16 / 24 / 36)"));
    const sizes_row = try row(cx, 24);
    inline for (.{ 16, 24, 36 }) |sz| {
        const rn = try W.Rate(.{ .count = 5, .value = 3, .size = @as(f32, sz) }).mount(scope, cx);
        try sizes_row.appendChild(a, rn.wrapper);
    }
    try c.appendChild(a, sizes_row);
    return c;
}
```

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

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.

### RateProps

`ui.widgets.Rate`

[src/ui/components/rate/mod.zig:28](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/rate/mod.zig#L28)

```zig
fn Rate(props: RateProps) RateBuilder
```

| Champ | Type | Défaut | Description |
| --- | --- | --- | --- |
| `count` | `u8` | `5` | — |
| `value` | `f32` | `0` | — |
| `disabled` | `bool` | `false` | — |
| `size` | `f32` | `24` | — |
| `on_change` | `?core.HandlerRef` | `null` | — |
| `star_icon_asset` | `svg_assets.Asset` | `svg_assets.common.star_filled` | 星标图标。默认实心星（common.star\_filled，亮/灭只靠 tint 区分）； 可换成自定义 SVG（心形、描边星等）。曾经默认为 null 时退化成 "\*" 文本。 |

### RateResult

`ui.widgets.Rate`

[src/ui/components/rate/mod.zig:128](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/rate/mod.zig#L128)

| Champ | Type | Défaut | Description |
| --- | --- | --- | --- |
| `wrapper` | `*Node` | — | — |
| `state` | `*RateState` | — | — |
