Textarea
ui.widgets.Textarea多行编辑,支持 helper、error 和禁用态。Multi-line editing with helper, error and disabled states.
BEHAVIOR CONTRACT
换行、选区、滚动、字素边界、IME preedit / commit 与单行输入保持一致。Line breaks, selection, scrolling, grapheme boundaries and IME preedit / commit match the single-line input.
RECORDED INTERACTION
Harness 聚焦文本框并写入两行内容。The harness focuses the box and writes two lines.
// ── 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;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。The story's verbatim source from the Storybook (zenit 5f9add5+wip 2026-09-30). W is ui.widgets; col / row / label are small Storybook layout helpers.