---
title: "Rate コンポーネント — zenit Zig UI"
description: "星評価、または上限付きの個数による評価。count、value、サイズ、読み取り専用に対応し、hover のプレビューは確定値と一致します。"
url: https://zenit.z.express/ja/components/rate
language: ja
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_ko: https://zenit.z.express/ko/components/rate.md
alternate_fr: https://zenit.z.express/fr/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`

星評価、または上限付きの個数による評価。

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

**BEHAVIOR CONTRACT**

count、value、サイズ、読み取り専用に対応し、hover のプレビューは確定値と一致します。

**RECORDED INTERACTION**

5 項目と 10 項目、読み取り専用、3 種類のサイズを示します。

`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;
}
```

[GitHub でソースを見るexamples/storybook/stories.zig:2393](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L2393)

Storybook にあるこの story のコードそのままです（zenit 5f9add5+wip 2026-09-30）。`W` は `ui.widgets` のことで、`col` / `row` / `label` は 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
```

| フィールド | 型 | デフォルト値 | 説明 |
| --- | --- | --- | --- |
| `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)

| フィールド | 型 | デフォルト値 | 説明 |
| --- | --- | --- | --- |
| `wrapper` | `*Node` | — | — |
| `state` | `*RateState` | — | — |
