← Interface components

UI.TextInput

luastra/ui
UI.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

inputsemantic

Parameters

ParameterType / valuesDescription
idlowercase path, requiredUnique field ID.
labelstring, requiredAccessible field name.
valuestring, requiredControlled value from application state.
multilineboolean?Uses a multiline host control when true.
maximumLengthinteger 1…4096?Native and protocol-enforced text length ceiling.
onInputaction string, requiredReceives committed composition-safe input in app.handle.
onSubmitaction string?Receives non-composing Enter; Shift+Enter remains a multiline line break.
textStyleUI.TextStyle?Local packaged font and bounded size, weight, lineHeight and fallback. Requires the 0.3 source SDK; omitted fields retain defaults.
paddingnone | xs | sm | md | lg | xl | responsiveAll-side inner spacing; responsive is supported only by padding. Group: Layout and surfaces.
marginnone | xs | sm | md | lg | xlAll-side outer spacing. Group: Layout and surfaces.
paddingX / paddingYnone | xs | sm | md | lg | xlAxis-specific inner spacing. Group: Layout and surfaces.
paddingTop / paddingBottom / paddingStart / paddingEndnone | xs | sm | md | lg | xlLogical side-specific inner spacing. Group: Layout and surfaces.
marginX / marginYnone | xs | sm | md | lg | xlAxis-specific outer spacing. Group: Layout and surfaces.
marginTop / marginBottom / marginStart / marginEndnone | xs | sm | md | lg | xlLogical side-specific outer spacing. Group: Layout and surfaces.
surfaceplain | card | elevated | accentBackground, border, and elevation. Group: Layout and surfaces.
widthfull | content | wideAvailable width, 720 px maximum, or 1180 px maximum. Group: Layout and surfaces.
classNamesafe string ≤ 256 bytesAdditional admitted class tokens. Group: Layout and surfaces.
hiddenbooleanVisibility state. Group: State and semantics.
disabledbooleanDisabled state. Group: State and semantics.
busybooleanaria-busy state. Group: State and semantics.
requiredbooleanRequired input state. Group: State and semantics.
errorIdcomponent idAssociates a visible role=alert. Group: State and semantics.
inputTypetext | email | passwordNative field type. Group: TextInput.
inputModedecimal | email | numeric | search | tel | text | urlPreferred mobile keyboard. Group: TextInput.
enterKeyHintdone | enter | go | next | previous | search | sendEnter-key behavior. Group: TextInput.
autoCompletesupported tokenAutofill 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 learning

Prerequisites

UI.Text

Complete inventory

View all pages in Interface components
← Previous: UI.ShapeNext: UI.List →