Skip to main content

Handling Text Input

TextInput adapts its text-entry surface to the active runtime. In automatic mode, lean-back targets use the TV keyboard dialog, touch Web uses a DOM input, and native phone/tablet targets use the system input path.

Controlled Input

TextInput({
id: 'nameInput',
placeholderText: 'Enter your name',
text: this.name,
width: 600,
height: 72,
}).onTextChange((event) => {
this.name = event.text;
})

Store this.name as an @state field when the rest of the view renders it. TextInput also updates its own text state before emitting onTextChange.

Password, Number, and Email Inputs

Use inputType, not a password boolean:

import {
TextInput,
TextInputType,
} from '@hs-src/hosanna-ui/views/controls/TextInput';

TextInput({
id: 'passwordInput',
placeholderText: 'Password',
inputType: TextInputType.Password,
width: 600,
height: 72,
})

The current enum values are Text, Password, Number, and Email. Treat these as keyboard/input hints; validate the submitted application value yourself.

Submission and Native Keyboard Control

onSubmit fires when a native IME reports its Return action:

TextInput({
id: 'emailInput',
inputType: TextInputType.Email,
text: this.email,
}).onSubmit((event) => {
this.email = event.text;
this.submitSignIn();
})

TextInputView.focusNativeInput() and blurNativeInput() control the system keyboard in the native mobile render mode. They are no-ops for TV and Web render modes. Look up the concrete TextInputView when calling them:

this.getSubView<TextInputView>('emailInput')?.focusNativeInput();

Important Fields

FieldPurpose
textCurrent value
placeholderTextText shown when empty
inputTypeText, password, number, or email behavior
renderModeauto, tv, web, or mobile; normally leave as auto
styleKeyAppConfig control style
width, heightInput bounds
iconUri, iconColor, iconSizeOptional icon presentation
onTextChangeReceives { text, type, view, preventDefault }
onSubmitNative IME submission callback

Prefer stable IDs, preserve the input value in app state, and test both the browser input path and the actual target keyboard before release.

See the current TextInput implementation and the hosanna-ui-samples-public MultiControlsRig for a runnable example.

Talk to us