Components/Text input

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
text input · dart_tui
Text input demo

TextInputModel

PropertyTypeDescription
valueStringCurrent text content.
cursorPosintCursor index within value.
placeholderStringShown when the value is empty.
labelStringLabel rendered before the field.
echoModeEchoModenormal or password (masked).
charLimitintMax characters. 0 = unlimited.
validatebool Function(String)?Called on Enter; return false to reject and emit ValidationFailedMsg.
suggestionsList<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

Related