← Back to Home • Next: Input — Methods →
Single-line, free-text entry. The user types plain text and confirms with Enter.
The Input control is the workhorse for collecting any unstructured string — a name, an
e-mail address, a URL, a search term, a note. It supports live character filtering, case
coercion, length limits, confirmation-time validation, Tab autocomplete suggestions, and
persistent history — all through a single fluent chain.
🔒 Need to hide what the user types (passwords, API keys, PINs)? Use the Secret control instead. It’s related, not identical:
Secretadds the mask character but deliberately dropsDefault/DefaultIfEmpty,EnableHistory, and both suggestion methods — a secret shouldn’t be pre-seeded, persisted, or suggested.
| Sub-page | What you will find |
|---|---|
| Index (this page) | What it is, when to use it, a first working example, the method map |
| Methods | Every fluent method — signature, parameters, defaults, and a snippet |
| Operations | Keyboard, validation flow, history, autocomplete, and edge cases |
| Styles | The InputStyles regions and how to recolor them |
Use Input when… |
Consider instead… |
|---|---|
| You need any free-form string | — |
| The value is a password or secret | Secret |
| The value must match a fixed pattern (date, phone, currency) | MaskEdit |
| The user should pick from a known list | Select |
using PromptPlusLibrary;
var result = PromptPlus.Controls
.Input("Your name")
.Run();
if (!result.IsAborted)
PromptPlus.Console.WriteLine($"Hello, {result.Content}!");
Input("Your name") creates the control. The first argument is the prompt; an optional
second argument is a description line shown under it..Run() renders the field and blocks until the user presses Enter (confirm) or Esc (abort).ResultPrompt<string>: read .Content
for the text and .IsAborted to detect Esc.⚠️ Always check
IsAbortedbefore using.Content. On abort,.Contentis not guaranteed to be empty — it holds whatever is currently in the buffer (a seededDefaultthe user never typed over, or partially-typed text).
using PromptPlusLibrary;
var pin = PromptPlus.Controls
.Input("PIN", "Only digits are accepted (max 5)")
.AcceptInput(char.IsDigit) // reject any non-digit keystroke
.MaxLength(5) // stop accepting after 5 characters
.PredicateValid(v => v.Length == 5
? (true, null)
: (false, "PIN must be exactly 5 digits")) // validate on Enter
.Run();
if (!pin.IsAborted)
PromptPlus.Console.WriteLine($"PIN accepted.");
This shows the three most common building blocks together: per-keystroke filtering
(AcceptInput), a hard length cap (MaxLength), and confirmation-time validation with a
message (PredicateValid). See Operations for how they interact.
Grouped by purpose. Full signatures and examples are on the Methods page.
| Purpose | Methods |
|---|---|
| Seed a value | Default, DefaultIfEmpty |
| Restrict typing | AcceptInput, MaxLength, InputToCase |
| Validate on confirm | PredicateValid, PredicateValidAsync |
| Autocomplete | SuggestionHandler, SuggestionHandlerAsync, MinimumSuggestionLength |
| History | EnableHistory |
| Dynamic description | ChangeDescription, ChangeDescriptionAsync |
| Appearance & behavior | Styles, Options |
| Run | Run |
Input returns ResultPrompt<string>.
| Member | Meaning |
|---|---|
.Content |
The confirmed text — or whatever is in the buffer at the moment of an abort, not necessarily empty |
.IsAborted |
true when the user pressed Esc / the abort key |
var (text, aborted) = PromptPlus.Controls.Input("Name").Run();
if (!aborted) PromptPlus.Console.WriteLine(text);