4.3k

Textarea

Multi-line text entry. Like input, text and placeholder bind from the model and on-input names a Msg variant that receives every edit as a canvas.TextInputEvent. Enter (and Shift+Enter) inserts a newline instead of submitting; when a textarea carries on-submit, the submit rides the primary chord — Cmd+Enter on macOS, Ctrl+Enter elsewhere. Give it a definite width and height (or a grow) to size the editing box.

textarea
A textarea rendered by the engine (light theme)

Markup

<textarea width="320" height="96" placeholder="Write a release note" text="{draft}" on-input="draft_edited" />

Zig builder

ui.el(.textarea, .{
    .width = 320,
    .height = 96,
    .placeholder = "Write a release note",
    .text = model.draft,
    .on_input = Ui.inputMsg(.draft_edited),
}, .{})

Attributes

AttributeDescription
textText value for text-bearing elements; a literal or one {binding}.
placeholderHint text shown while a text entry is empty.
disabledDisables the control; true/false or a {binding}.
autofocusFocusable controls only: moves keyboard focus to the element when it mounts or when the value turns on (edge-triggered - holding it true never re-steals focus). The TEA way to focus an editor on create.
on-inputNames a Msg variant with canvas.TextInputEvent payload; delivers each text edit.
on-submitDispatch a Msg on submit: tag or tag:{payload}. Enter in a text field, primary+enter in a textarea; on a list-item, plain Enter dispatches it as the row's primary action while Space keeps the row's select (on-press).