TextBox

Description

The TextBox component enables users to input text data in your application. It is designed for use in forms or any area where textual input is required. As part of the Components group, it provides a simple and uniform way to collect string inputs, with additional customization options for placeholders, read-only modes, password inputs, and styling.

Usage

To use the TextBox component, import the Tesserae UI library and instantiate it using the static helper method. The following sample demonstrates how to create basic TextBox instances including a standard, disabled, read-only, password, and required state.

API reference

class

TextBox

public class TextBox : Input<TextBox>, ITextFormating, IHasBackgroundColor, IHasForegroundColor, IRoundedStyle

A single-line text input component.

Namespace
Tesserae
Inheritance
Input<TextBox> → TextBox
Implements
ITextFormating, IHasBackgroundColor, IHasForegroundColor, IRoundedStyle

Constructors

NameDescription
TextBoxInitializes a new instance of the TextBox class.
Constructor
TextBox
public TextBox(string text = string.Empty) : base("text", text)

Initializes a new instance of the TextBox class.

Parameters

text
The initial text.

Properties

NameDescription
PlaceholderGets or sets the placeholder text.
IsReadOnlyGets or sets whether the text box is read-only.
MaxLengthGets or sets the maximum length of the text.
IsPasswordGets or sets whether the text box is in password mode.
SizeGets or sets the text size.
WeightGets or sets the text weight.
TextAlignGets or sets the text alignment.
BackgroundGets or sets the background color.
ForegroundGets or sets the foreground color.
Property
TextBox.Placeholder
public string Placeholder { get ; set ; }

Gets or sets the placeholder text.

Property
TextBox.IsReadOnly
public bool IsReadOnly { get ; set ; }

Gets or sets whether the text box is read-only.

Property
TextBox.MaxLength
public int MaxLength { get ; set ; }

Gets or sets the maximum length of the text.

Property
TextBox.IsPassword
public bool IsPassword { get ; set ; }

Gets or sets whether the text box is in password mode.

Property
TextBox.Size
public virtual TextSize Size { get ; set ; }

Gets or sets the text size.

Property
TextBox.Weight
public virtual TextWeight Weight { get ; set ; }

Gets or sets the text weight.

Property
TextBox.TextAlign
public TextAlign TextAlign { get ; set ; }

Gets or sets the text alignment.

Property
TextBox.Background
public string Background { get ; set ; }

Gets or sets the background color.

Property
TextBox.Foreground
public string Foreground { get ; set ; }

Gets or sets the foreground color.

Methods

NameDescription
SetPlaceholderSets the placeholder text.
ReadOnlySets the text box as read-only.
PasswordSets the text box to password mode.
NoBorderRemoves the border from the text box.
NoMinWidthRemoves the default minimum width.
UnlockHeightUnlocks the height restriction.
Method
TextBox.SetPlaceholder
public TextBox SetPlaceholder(string placeholder)

Sets the placeholder text.

Parameters

placeholder
The placeholder text.

Returns

The current instance.

Method
TextBox.ReadOnly
public TextBox ReadOnly()

Sets the text box as read-only.

Method
TextBox.Password
public TextBox Password()

Sets the text box to password mode.

Method
TextBox.NoBorder
public TextBox NoBorder()

Removes the border from the text box.

Method
TextBox.NoMinWidth
public TextBox NoMinWidth()

Removes the default minimum width.

Method
TextBox.UnlockHeight
public TextBox UnlockHeight()

Unlocks the height restriction.

Samples

Basic and Customized TextBox Examples

The following sample demonstrates creating multiple TextBox variations including standard, disabled, read-only, password input, required state, error messaging, placeholder text, and validation options.

See also

  • Label – Frequently used together with TextBox for providing descriptive text.
  • Button – Often paired with TextBox when used in forms for submitting data.
© 2026 Curiosity. All rights reserved.