Skip to main content
TextInput is a single-line text field with cursor navigation, placeholder text, character limits, autocomplete suggestions, and multiple echo modes including password masking.

Quick start

Always call TextInput::blink from init() to start the cursor blink loop. Without it, the cursor will not animate.

Constructor

TextInput() creates the field with a > prompt, normal echo mode, no character limit, and an unfocused cursor.

Core methods

Value

Focus and blur

Cursor position

Placeholder text

The placeholder is shown when the field is empty. It uses placeholderStyle (dim by default) and the first character sits under the cursor.

Character limit

When the limit is reached, further input is silently dropped.

Width

When the input value is wider than width, the visible portion scrolls horizontally to keep the cursor in view.

Echo modes

Validation

TextInput validates input internally via its ValidateFunction interface. The function receives the proposed value as a char[] after each keystroke; returning false prevents the change from being applied.
The ValidateFunction interface is package-private. To apply input validation, subclass TextInput and override setValue to apply your own logic, or filter acceptable characters upstream before passing them to the component.

Autocomplete suggestions

Styling

Key bindings

Textarea

Multi-line text editor.

Components overview

Back to all components.