TextBox is a single-line text editor.
var name = new State<string>("Alex");
new TextBox().Text(name);
You can also pass initial text:
new TextBox("Hello");
TextBox supports undo/redo:
Ctrl+Z: undoCtrl+R: redoSee Undo/Redo.
TextBox can mask its text to behave like a password input:
new TextBox("hunter2")
.IsPassword(true)
.ClipboardMode(TextBoxClipboardMode.Disabled)
.PasswordRevealMode(PasswordRevealMode.WhileFocused);
Masking uses the glyph configured by TextBoxStyle.PasswordMaskGlyph.
When content is wider than the viewport, the TextBox can show start/end indicators configured by TextBoxStyle (arrows/ellipsis variants).
Text: the current text (bindable, supports State<string> two-way binding via fluent API).TextAlignment: left/center/right alignment inside the editor.IsPassword: enables masking.PasswordRevealMode: controls when the real text is revealed.ClipboardMode: enables/disables copy/cut/paste behaviors (useful for secrets).In password mode, copy/cut is typically disabled so the masked value doesn’t leak via clipboard.
HorizontalAlignment = Align.Start, VerticalAlignment = Align.StartTextBox uses background on the text region while keeping borders visually compatible with the terminal background.
TextBoxStyle also supports brush-based gradients:
new TextBox("Gradient-enabled")
.Style(TextBoxStyle.Default with
{
BackgroundBrush = Brush.LinearGradient(
new GradientPoint(0f, 0f),
new GradientPoint(1f, 0f),
[new GradientStop(0f, Color.Rgb(0x11, 0x25, 0x3D)), new GradientStop(1f, Color.Rgb(0x12, 0x20, 0x33))]),
ForegroundBrush = Brush.LinearGradient(
new GradientPoint(0f, 0f),
new GradientPoint(1f, 0f),
[new GradientStop(0f, Colors.White), new GradientStop(1f, Colors.DeepSkyBlue)]),
});
See also: