---
title: "Componente Tag — zenit Zig UI"
description: "Etiquetas de categoría que se pueden cerrar o de solo lectura. El color, variant, size, closable y los callbacks comparten un tamaño y un foco coherentes."
url: https://zenit.z.express/es/components/tag
language: es
alternate_en: https://zenit.z.express/components/tag.md
alternate_zh: https://zenit.z.express/zh/components/tag.md
alternate_ja: https://zenit.z.express/ja/components/tag.md
alternate_ko: https://zenit.z.express/ko/components/tag.md
alternate_fr: https://zenit.z.express/fr/components/tag.md
alternate_de: https://zenit.z.express/de/components/tag.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Tag

`ui.widgets.Tag`

Etiquetas de categoría que se pueden cerrar o de solo lectura.

[Video](https://zenit.z.express/media/stories/tag.mp4?v=419895656d)

**BEHAVIOR CONTRACT**

El color, variant, size, closable y los callbacks comparten un tamaño y un foco coherentes.

**RECORDED INTERACTION**

Muestra colores neutral, accent y de estado, además de outline.

`examples/storybook/stories.zig:552`

```zig
// ── Tag ──
pub fn buildTag(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);

    // ── 全部颜色（含 info）──
    const r1 = try row(cx, 8);
    inline for (.{ W.TagColor.neutral, .accent, .success, .warning, .danger, .info }, .{ "neutral", "accent", "success", "warning", "danger", "info" }) |col_, t| {
        try r1.appendChild(a, try W.Tag(.{ .text = t, .color = col_ }).mount(scope, cx));
    }
    try c.appendChild(a, try label(cx, "Colors"));
    try c.appendChild(a, r1);

    // ── 尺寸 ──
    try c.appendChild(a, try label(cx, "Sizes (sm / md)"));
    const r_sz = try row(cx, 8);
    inline for (.{ W.TagSize.sm, .md }, .{ "Small", "Medium" }) |sz, t| {
        try r_sz.appendChild(a, try W.Tag(.{ .text = t, .color = .accent, .size = sz }).mount(scope, cx));
    }
    try c.appendChild(a, r_sz);

    // ── 变体 ──
    try c.appendChild(a, try label(cx, "Variants"));
    const r2 = try row(cx, 8);
    try r2.appendChild(a, try W.Tag(.{ .text = "Default", .variant = .default }).mount(scope, cx));
    try r2.appendChild(a, try W.Tag(.{ .text = "Outline", .variant = .outline }).mount(scope, cx));
    try r2.appendChild(a, try W.Tag(.{ .text = "Closable", .closable = true }).mount(scope, cx));
    try r2.appendChild(a, try W.Tag(.{ .text = "Outline + close", .variant = .outline, .color = .danger, .closable = true }).mount(scope, cx));
    try c.appendChild(a, r2);
    return c;
}
```

[Ver el código en GitHubexamples/storybook/stories.zig:552](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L552)

El código literal de la story en el Storybook (zenit 5f9add5+wip 2026-09-30). `W` es `ui.widgets`; `col` / `row` / `label` son pequeños helpers de layout del Storybook.

### TagProps

`ui.widgets.Tag`

[src/ui/components/tag/mod.zig:77](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/tag/mod.zig#L77)

```zig
fn Tag(props: TagProps) TagBuilder
```

| Campo | Tipo | Predeterminado | Descripción |
| --- | --- | --- | --- |
| `text` | `[]const u8` | `""` | — |
| `variant` | `TagVariant` `.default` `.outline` | `.default` | — |
| `color` | `TagColor` `.neutral` `.accent` `.success` `.warning` `.danger` `.info` | `.neutral` | — |
| `size` | `TagSize` `.sm` `.md` | `.md` | — |
| `closable` | `bool` | `false` | — |
| `on_close` | `?core.HandlerRef` | `null` | — |
| `close_icon_asset` | `?svg_assets.Asset` | `null` | — |

### \*Node

`ui.widgets.Tag`

mount devuelve `*Node` directamente: añádelo a un nodo padre.
