components/textarea
入力とフォーム · 09 / 64

Textarea

ui.widgets.Textarea

helper、error、無効状態に対応した複数行編集。

BEHAVIOR CONTRACT

改行、選択範囲、スクロール、書記素境界、IME の preedit / commit は 1 行入力と同じ挙動です。

RECORDED INTERACTION

harness がテキストボックスにフォーカスし、2 行を書き込みます。

examples/storybook/stories.zig:2923
// ── Textarea ──
pub fn buildTextarea(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);

    const ta = try W.Textarea(.{ .label_text = "Notes", .placeholder = "Write something…", .rows = 5, .width = 420 }).mount(scope, cx);
    ta.meta.ownership.meta.test_id = "story.textarea.box";
    try c.appendChild(a, ta);

    try c.appendChild(a, try W.Textarea(.{ .label_text = "With helper", .placeholder = "Bio", .helper = "Max 500 characters", .rows = 3, .width = 420 }).mount(scope, cx));
    try c.appendChild(a, try W.Textarea(.{ .label_text = "With error", .value = "too short", .error_msg = "Please write more", .rows = 3, .width = 420 }).mount(scope, cx));
    try c.appendChild(a, try W.Textarea(.{ .label_text = "Disabled", .placeholder = "Cannot edit", .disabled = true, .rows = 3, .width = 420 }).mount(scope, cx));
    return c;
}
GitHub でソースを見るexamples/storybook/stories.zig:2923

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

zenit · デュアルライセンスオープンソースプロジェクトは GPL-3.0-only のもとで無料で使えます。クローズドソースや商用製品には商用ライセンスが必要です。作者への連絡先:zongyi.xzy#gmail.com(# を @ に置き換え)zenit 5f9add5+wip 2026-09-30