---
title: "Chip component | zenit Zig UI"
description: "Compact choices, filters or icon tokens. active, outline, disabled, closable and icons reuse the control shell."
url: https://ui.surf/zenit/components/chip
language: en
alternate_zh: https://ui.surf/zenit/zh/components/chip.md
alternate_es: https://ui.surf/zenit/es/components/chip.md
alternate_ja: https://ui.surf/zenit/ja/components/chip.md
alternate_ko: https://ui.surf/zenit/ko/components/chip.md
alternate_fr: https://ui.surf/zenit/fr/components/chip.md
alternate_de: https://ui.surf/zenit/de/components/chip.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Chip

`ui.widgets.Chip`

Compact choices, filters or icon tokens.

[Video](https://ui.surf/zenit/media/stories/chip.mp4?v=68187de95d)

**BEHAVIOR CONTRACT**

active, outline, disabled, closable and icons reuse the control shell.

**RECORDED INTERACTION**

Sweeps states, sizes and icon combinations.

`examples/storybook/stories.zig:584`

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

    // ── 变体（含 disabled）──
    try c.appendChild(a, try label(cx, "Variants"));
    const r = try row(cx, 8);
    try r.appendChild(a, try W.Chip(.{ .label = "Default" }).mount(scope, cx));
    try r.appendChild(a, try W.Chip(.{ .label = "Active", .variant = .active }).mount(scope, cx));
    try r.appendChild(a, try W.Chip(.{ .label = "Outline", .variant = .outline }).mount(scope, cx));
    try r.appendChild(a, try W.Chip(.{ .label = "Disabled", .variant = .disabled }).mount(scope, cx));
    try r.appendChild(a, try W.Chip(.{ .label = "Closable", .closable = true }).mount(scope, cx));
    try c.appendChild(a, r);

    // ── 尺寸 ──
    try c.appendChild(a, try label(cx, "Sizes (xs / sm / md)"));
    const r_sz = try row(cx, 8);
    inline for (.{ W.ChipSize.xs, .sm, .md }, .{ "XS", "SM", "MD" }) |sz, t| {
        try r_sz.appendChild(a, try W.Chip(.{ .label = t, .size = sz, .variant = .active }).mount(scope, cx));
    }
    try c.appendChild(a, r_sz);

    // ── 带图标 ──
    try c.appendChild(a, try label(cx, "With icon"));
    const r_ic = try row(cx, 8);
    try r_ic.appendChild(a, try W.Chip(.{ .label = "Starred", .icon_asset = icons.star }).mount(scope, cx));
    try r_ic.appendChild(a, try W.Chip(.{ .label = "Folder", .icon_asset = icons.folder, .closable = true }).mount(scope, cx));
    try c.appendChild(a, r_ic);
    return c;
}
```

[View source on GitHubexamples/storybook/stories.zig:584](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L584)

The story's verbatim source from the Storybook (zenit 4c50245 2026-10-01). `W` is `ui.widgets`; `col` / `row` / `label` are small Storybook layout helpers.

### ChipProps

`ui.widgets.Chip`

[src/ui/components/chip/mod.zig:59](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/chip/mod.zig#L59)

```zig
fn Chip(props: ChipProps) ChipBuilder
```

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `[]const u8` | — | — |
| `size` | `ChipSize` `.xs` `.sm` `.md` | `.sm` | — |
| `variant` | `ChipVariant` `.default` `.active` `.outline` `.disabled` | `.default` | — |
| `icon_asset` | `?svg_assets.Asset` | `null` | — |
| `closable` | `bool` | `false` | — |
| `readonly` | `bool` | `true` | — |
| `on_click` | `?core.HandlerRef` | `null` | — |
| `on_close` | `?core.HandlerRef` | `null` | — |

### \*Node

`ui.widgets.Chip`

mount returns `*Node` directly. Append it to a parent.
