---
title: "TagsInput コンポーネント — zenit Zig UI"
description: "キーボードで複数の token を続けて入力します。カンマ / Enter での確定、削除、フォーカス、tag リストの更新はすべて書記素単位で安全に処理されます。"
url: https://zenit.z.express/ja/components/tags
language: ja
alternate_en: https://zenit.z.express/components/tags.md
alternate_zh: https://zenit.z.express/zh/components/tags.md
alternate_es: https://zenit.z.express/es/components/tags.md
alternate_ko: https://zenit.z.express/ko/components/tags.md
alternate_fr: https://zenit.z.express/fr/components/tags.md
alternate_de: https://zenit.z.express/de/components/tags.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# TagsInput

`ui.widgets.TagsInput`

キーボードで複数の token を続けて入力します。

[Video](https://zenit.z.express/media/stories/tags.mp4?v=85989d0ec2)

**BEHAVIOR CONTRACT**

カンマ / Enter での確定、削除、フォーカス、tag リストの更新はすべて書記素単位で安全に処理されます。

**RECORDED INTERACTION**

harness が「docs,」と入力すると、新しい tag として確定されます。

`examples/storybook/stories.zig:3042`

```zig
// ── TagsInput ──
pub fn buildTagsInput(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    const ti = try ui.widgets.TagsInput(.{
        .initial_tags = &.{ "zig", "metal" },
        .width = 380,
    }, scope, cx);
    ti.input.meta.ownership.meta.test_id = "story.tags.input";
    ti.wrapper.meta.ownership.meta.test_id = "story.tags.wrapper";
    try c.appendChild(a, ti.wrapper);
    try c.appendChild(a, try label(cx, "End with comma (or click Add) to commit a tag."));
    return c;
}
```

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

Storybook にあるこの story のコードそのままです（zenit 5f9add5+wip 2026-09-30）。`W` は `ui.widgets` のことで、`col` / `row` / `label` は Storybook 内の小さなレイアウトヘルパーです。

### TagsInputProps

`ui.widgets.TagsInput`

[src/ui/components/tags\_input/mod.zig:21](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/tags_input/mod.zig#L21)

```zig
fn mountTagsInput(props: TagsInputProps, scope: *Scope, cx: *Cx) !TagsInputMount
```

| フィールド | 型 | デフォルト値 | 説明 |
| --- | --- | --- | --- |
| `initial_tags` | `[]const []const u8` | `&.{}` | — |
| `max_tags` | `usize` | `16` | — |
| `width` | `f32` | `360` | — |
| `placeholder` | `[]const u8` | `"Add tag, end with comma"` | — |
| `on_change` | `?core.HandlerRef` | `null` | — |

### TagsInputMount

`ui.widgets.TagsInput`

[src/ui/components/tags\_input/mod.zig:229](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/tags_input/mod.zig#L229)

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