TextArea
Description
A control to input multiple lines of text
TextAreas allow users to enter and edit multi-line text. They are commonly used for comments, descriptions, or any input that requires multiple lines of text.
API reference
public sealed class TextArea : ComponentBase<TextArea, HTMLTextAreaElement>, ICanValidate<TextArea>, IObservableComponent<string>, ITabIndex, IRoundedStyleA multi-line text input component.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<TextArea, HTMLTextAreaElement> → TextArea
- Implements
- ICanValidate<TextArea>, IObservableComponent<string>, ITabIndex, IRoundedStyle
Constructors
| Name | Description |
|---|---|
| TextArea | Initializes a new instance of the TextArea class. |
Properties
| Name | Description |
|---|---|
| TabIndex | Gets or sets the tab index. |
| IsEnabled | Gets or sets whether the component is enabled. |
| IsReadOnly | Gets or sets whether the component is read-only. |
| Text | Gets or sets the text in the text area. |
| Placeholder | Gets or sets the placeholder text. |
| Error | Gets or sets the error message. |
| MaxLength | Gets or sets the maximum length of the text. |
| IsInvalid | Gets or sets whether the component is in an invalid state. |
| IsRequired | Gets or sets whether the component is required. |
public bool IsEnabled { get ; set ; }Gets or sets whether the component is enabled.
public bool IsReadOnly { get ; set ; }Gets or sets whether the component is read-only.
public string Placeholder { get ; set ; }Gets or sets the placeholder text.
public int MaxLength { get ; set ; }Gets or sets the maximum length of the text.
public bool IsInvalid { get ; set ; }Gets or sets whether the component is in an invalid state.
Methods
| Name | Description |
|---|---|
| Render | Renders the component. |
| Attach | Attaches a handler to the input updated event. |
| SetText | Sets the text of the text area. |
| ClearText | Clears the text. |
| SetPlaceholder | Sets the placeholder text. |
| Disabled | Sets whether the component is disabled. |
| ReadOnly | Sets the component as read-only. |
| NoSpellCheck | Disables spell check. |
| Required | Sets the component as required. |
| Focus | Sets focus to the text area. |
| AsObservable | Returns an observable of the text. |
| AutoResize | Enables auto-resizing of the text area as the user types, based on the scrollHeight. |
public override HTMLElement Render()Renders the component.
Returns
The rendered HTML element.
public void Attach(ComponentEventHandler<TextArea> handler)Attaches a handler to the input updated event.
Parameters
- handler
- The handler.
public TextArea SetText(string text)Sets the text of the text area.
Parameters
- text
- The text.
Returns
The current instance.
public TextArea SetPlaceholder(string placeholder)Sets the placeholder text.
Parameters
- placeholder
- The placeholder text.
Returns
The current instance.
public TextArea Disabled(bool value = true)Sets whether the component is disabled.
Parameters
- value
- Whether it's disabled.
Returns
The current instance.
public IObservable<string> AsObservable()Returns an observable of the text.
public TextArea AutoResize(bool allowShrink = true, int? minHeight = null, int? maxHeight = null)Enables auto-resizing of the text area as the user types, based on the scrollHeight.
Parameters
- allowShrink
- If false, the text area will not shrink below its initial size.
- minHeight
- If set, specifies a minimum pixel height for the text area.
- maxHeight
- If set, specifies a maximum pixel height for the text area. Content will scroll if it exceeds this height.
Returns
The current instance.