The TextField component in the Scripting app provides a declarative way to create a text input field, similar to SwiftUI’s TextField. It supports both single-line and multiline input, custom labels, placeholder prompts, scroll direction, focus handling, and line constraints.
This component is ideal for collecting short inputs like usernames or longer inputs like messages, with seamless integration into reactive view hierarchies.
| Property | Type | Description |
|---|---|---|
title |
string |
A simple string label displayed alongside the field. (Required if label is not used) |
label |
VirtualNode |
A custom node-based label. (Use instead of title) |
value |
string |
The current text input value. |
onChanged |
(value: string) => void |
Callback triggered whenever the input text changes. |
prompt |
string (optional) |
A hint or placeholder to guide the user’s input. |
axis |
"horizontal" | "vertical" (optional) |
Scroll direction when content exceeds bounds. Use "vertical" for multiline support. |
autofocus |
boolean (optional) |
If true, the field receives focus on mount. Default is false. |
onFocus |
() => void (optional) |
Called when the field gains focus. |
onBlur |
() => void (optional) |
Called when the field loses focus. |
prompt is shown as placeholder text until input is provided.title or label, not both.axis="vertical" and define a lineLimit.TextField integrates seamlessly with state hooks like useState to enable real-time reactivity.