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
public class TextBox : Input<TextBox>, ITextFormating, IHasBackgroundColor, IHasForegroundColor, IRoundedStyleA single-line text input component.
- Namespace
- Tesserae
- Inheritance
- Input<TextBox> → TextBox
- Implements
- ITextFormating, IHasBackgroundColor, IHasForegroundColor, IRoundedStyle
Constructors
| Name | Description |
|---|---|
| TextBox | Initializes a new instance of the TextBox class. |
Properties
| Name | Description |
|---|---|
| Placeholder | Gets or sets the placeholder text. |
| IsReadOnly | Gets or sets whether the text box is read-only. |
| MaxLength | Gets or sets the maximum length of the text. |
| IsPassword | Gets or sets whether the text box is in password mode. |
| Size | Gets or sets the text size. |
| Weight | Gets or sets the text weight. |
| TextAlign | Gets or sets the text alignment. |
| Background | Gets or sets the background color. |
| Foreground | Gets or sets the foreground color. |
public string Placeholder { get ; set ; }Gets or sets the placeholder text.
public bool IsReadOnly { get ; set ; }Gets or sets whether the text box is read-only.
public int MaxLength { get ; set ; }Gets or sets the maximum length of the text.
public bool IsPassword { get ; set ; }Gets or sets whether the text box is in password mode.
public string Background { get ; set ; }Gets or sets the background color.
Methods
| Name | Description |
|---|---|
| SetPlaceholder | Sets the placeholder text. |
| ReadOnly | Sets the text box as read-only. |
| Password | Sets the text box to password mode. |
| NoBorder | Removes the border from the text box. |
| NoMinWidth | Removes the default minimum width. |
| UnlockHeight | Unlocks the height restriction. |
public TextBox SetPlaceholder(string placeholder)Sets the placeholder text.
Parameters
- placeholder
- The placeholder text.
Returns
The current instance.
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.