UI.TextInput
luastra/uiUI.TextInput(input: Input): Node
Creates a controlled single-line or multiline field with maximum length, submit action, keyboard hints, autofill metadata, validation semantics, selection preservation, and composition-safe delivery.
Mental model
This is a declarative node: app.render describes it again from current state, while the host matches its stable id to the existing view.
Before you use it
Add luastra/ui to this module's dependencies in luastra.json, then import it with require("luastra/ui"). The project must declare the ui.render capability. app.render must return one UI.Screen root; place this node inside that tree rather than invoking it for a hidden side effect.
How it fits
The constructor validates its fields immediately and returns a UI.Node. After app.render returns, the host reconciles that node by stable id with the current semantic DOM-based interface. Current desktop and mobile hosts package the same web artifact; native adapters are used at capability boundaries.
When to use it
Use UI.TextInput for editable text, email, password, search, telephone, numeric, or multiline entry. Update state from onInput; onSubmit ignores active IME composition and Shift+Enter preserves a multiline line break.
Shared parameter groups
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| id | lowercase path, required | Unique field ID. |
| label | string, required | Accessible field name. |
| value | string, required | Controlled value from application state. |
| multiline | boolean? | Uses a multiline host control when true. |
| maximumLength | integer 1…4096? | Native and protocol-enforced text length ceiling. |
| onInput | action string, required | Receives committed composition-safe input in app.handle. |
| onSubmit | action string? | Receives non-composing Enter; Shift+Enter remains a multiline line break. |
| textStyle | UI.TextStyle? | Local packaged font and bounded size, weight, lineHeight and fallback. Requires the 0.3 source SDK; omitted fields retain defaults. |
| padding | none | xs | sm | md | lg | xl | responsive | All-side inner spacing; responsive is supported only by padding. Group: Layout and surfaces. |
| margin | none | xs | sm | md | lg | xl | All-side outer spacing. Group: Layout and surfaces. |
| paddingX / paddingY | none | xs | sm | md | lg | xl | Axis-specific inner spacing. Group: Layout and surfaces. |
| paddingTop / paddingBottom / paddingStart / paddingEnd | none | xs | sm | md | lg | xl | Logical side-specific inner spacing. Group: Layout and surfaces. |
| marginX / marginY | none | xs | sm | md | lg | xl | Axis-specific outer spacing. Group: Layout and surfaces. |
| marginTop / marginBottom / marginStart / marginEnd | none | xs | sm | md | lg | xl | Logical side-specific outer spacing. Group: Layout and surfaces. |
| surface | plain | card | elevated | accent | Background, border, and elevation. Group: Layout and surfaces. |
| width | full | content | wide | Available width, 720 px maximum, or 1180 px maximum. Group: Layout and surfaces. |
| className | safe string ≤ 256 bytes | Additional admitted class tokens. Group: Layout and surfaces. |
| hidden | boolean | Visibility state. Group: State and semantics. |
| disabled | boolean | Disabled state. Group: State and semantics. |
| busy | boolean | aria-busy state. Group: State and semantics. |
| required | boolean | Required input state. Group: State and semantics. |
| errorId | component id | Associates a visible role=alert. Group: State and semantics. |
| inputType | text | email | password | Native field type. Group: TextInput. |
| inputMode | decimal | email | numeric | search | tel | text | url | Preferred mobile keyboard. Group: TextInput. |
| enterKeyHint | done | enter | go | next | previous | search | send | Enter-key behavior. Group: TextInput. |
| autoComplete | supported token | Autofill hint. Group: TextInput. |
| motion | { [property]: Tween | Sequence } | Opacity, rotation, scale, and translation channels. Group: Events and motion. |
Children and layout
This component does not accept arbitrary child nodes; named parameters provide its content.
Accessibility and keyboard
label is required. required, disabled, and errorId expose state to screen readers; an error hint should be a visible role=alert.
Common mistakes
- Changing value outside application state.
- Treating intermediate IME composition as committed text.
Returns
Node — a validated declarative UI node that becomes part of the next host-neutral render tree.
What happens next
A validated declarative node appears after it is returned as part of the current render tree.
Failures and fixes
Invalid fields, duplicate IDs, unsupported child combinations, or a missing ui.render capability fail during check, render-tree validation, or host startup.
Availability
Source API in 0.5.0-alpha; the public installer targets 0.5.0-alpha. Verify host-specific behavior against the selected SDK.
Focused example
UI.TextInput {
id = "form/email",
label = "Email",
value = email,
onInput = "form.email-change",
inputType = "email",
inputMode = "email",
enterKeyHint = "next",
required = true,
}Continue with a complete recipe
This checked recipe uses UI.TextInput inside complete authored files with the required manifest, test, and run steps.
Open validate a form and confirm in a modal recipe