Text input
A single-line text field with a visible cursor, character limit, password EchoMode, on-submit validation, and Tab-completion suggestions. Understands emacs/readline editing keys.
Install the package
Every component ships in the single dart_tui package.
$dart pub add dart_tui

TextInputModel(
placeholder: 'Type something…',
label: 'Name',
charLimit: 80,
validate: (value) => value.trim().isNotEmpty,
);
// Password field:
TextInputModel(placeholder: 'Password', echoMode: EchoMode.password);TextInputModel
| Property | Type | Description |
|---|---|---|
| value | String | Current text content. |
| cursorPos | int | Cursor index within value. |
| placeholder | String | Shown when the value is empty. |
| label | String | Label rendered before the field. |
| echoMode | EchoMode | normal or password (masked). |
| charLimit | int | Max characters. 0 = unlimited. |
| validate | bool Function(String)? | Called on Enter; return false to reject and emit ValidationFailedMsg. |
| suggestions | List<String> | Tab-completion candidates. |
Keybindings
ctrl+a / ctrl+eJump to start / end of line
ctrl+b / ctrl+fMove one character left / right
alt+← / alt+→Move one word left / right
ctrl+w / alt+backspaceDelete the previous word