---
title: "Form component | zenit Zig UI"
description: "Typed form state, field metadata and validation timing. Values, dirty / touched, errors and on_blur / on_submit validation live in the form, not in node…"
url: https://ui.surf/zenit/components/form
language: en
alternate_zh: https://ui.surf/zenit/zh/components/form.md
alternate_es: https://ui.surf/zenit/es/components/form.md
alternate_ja: https://ui.surf/zenit/ja/components/form.md
alternate_ko: https://ui.surf/zenit/ko/components/form.md
alternate_fr: https://ui.surf/zenit/fr/components/form.md
alternate_de: https://ui.surf/zenit/de/components/form.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Form

`ui.widgets.FormOf(T)`

Typed form state, field metadata and validation timing.

[Video](https://ui.surf/zenit/media/stories/form.mp4?v=9ae9c123b3)

**BEHAVIOR CONTRACT**

Values, dirty / touched, errors and on\_blur / on\_submit validation live in the form, not in node callbacks.

**RECORDED INTERACTION**

The harness clicks Submit; required fields show their validation.

`examples/storybook/stories.zig:3140`

```zig
pub fn buildForm(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    _ = try ui.widgets.FormOf(DemoForm).create(scope, .{ .name = "", .email = "" }, .{ .trigger = .on_blur });
    // 表单字段 UI 用 Input 展示（FormOf 管校验状态；此 story 重在展示字段布局）
    try c.appendChild(a, try W.Input(.{ .label_text = "Name", .placeholder = "Full name", .width = 320, .required = true }).mount(scope, cx));
    try c.appendChild(a, try W.Input(.{ .label_text = "Email", .input_type = .email, .placeholder = "you@example.com", .width = 320, .required = true }).mount(scope, cx));
    try c.appendChild(a, try W.Button(.{ .label = "Submit", .variant = .primary }).mount(scope, cx));
    return c;
}
```

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

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.
