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.
Samples
Basic TextAreas
Auto Resize
Validation
API reference
public sealed class TextArea : ComponentBase<TextArea, HTMLTextAreaElement>, ICanValidate<TextArea>, IBindableComponent<string>, ITabIndex, IRoundedStyle, IDictationTargetA multi-line text input component.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<TextArea, HTMLTextAreaElement> → TextArea
- Implements
- ICanValidate<TextArea>, IBindableComponent<string>, ITabIndex, IRoundedStyle, IDictationTarget
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. |
| IsDictating | True while the microphone button is listening. |
| IsEditable | |
| CanDictate |
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.
public bool IsRequired { get ; set ; }Gets or sets whether the component is required.
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. |
| WithDictation | Adds a microphone button in the corner of the text area, as an OmniBox has with DictationButton: pressing it dictates after the text already in the field, pressing it again stops, and what was heard stays. The words come from provider, else Provider, else the browser's speech recognition; the button is not shown when none is available. |
| DictationSource | Sets where this field's dictation gets its words from, instead of Provider, without adding the microphone button: for a field that is dictated into from elsewhere (see DictationTargets). |
| StartDictation | Starts dictating, as pressing the microphone button does. Does nothing when already dictating or when nothing can supply words, and works whether or not WithDictation was called. |
| StopDictation | Stops dictating; what was heard stays in the text area. |
| GetDictation | The dictation of this field, made on first use so a field that never dictates carries none. |
| Focus | Sets focus to the text area. |
| AsObservable | Returns an observable of the text. |
| SetBoundValue | Programmatically updates the text area as part of a two-way binding (DOM input event is not raised). |
| 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 TextArea WithDictation(DictationProvider provider = null)Adds a microphone button in the corner of the text area, as an OmniBox has with DictationButton: pressing it dictates after the text already in the field, pressing it again stops, and what was heard stays. The words come from provider, else Provider, else the browser's speech recognition; the button is not shown when none is available.
Parameters
- provider
- The source of this field's dictation, instead of the application-wide one.
public TextArea DictationSource(DictationProvider provider)Sets where this field's dictation gets its words from, instead of Provider, without adding the microphone button: for a field that is dictated into from elsewhere (see DictationTargets).
public TextArea StartDictation()Starts dictating, as pressing the microphone button does. Does nothing when already dictating or when nothing can supply words, and works whether or not WithDictation was called.
public TextArea StopDictation()Stops dictating; what was heard stays in the text area.
private DictationController GetDictation()The dictation of this field, made on first use so a field that never dictates carries none.
public IObservable<string> AsObservable()Returns an observable of the text.
public void SetBoundValue(string value)Programmatically updates the text area as part of a two-way binding (DOM input event is not raised).
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.