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

class

TextArea

public sealed class TextArea : ComponentBase<TextArea, HTMLTextAreaElement>, ICanValidate<TextArea>, IBindableComponent<string>, ITabIndex, IRoundedStyle, IDictationTarget

A multi-line text input component.

Namespace
Tesserae
Inheritance
ComponentBase<TextArea, HTMLTextAreaElement> → TextArea
Implements
ICanValidate<TextArea>, IBindableComponent<string>, ITabIndex, IRoundedStyle, IDictationTarget

Constructors

NameDescription
TextAreaInitializes a new instance of the TextArea class.
Constructor
TextArea
public TextArea(string text = string.Empty)

Initializes a new instance of the TextArea class.

Parameters

text
The initial text.

Properties

NameDescription
TabIndexGets or sets the tab index.
IsEnabledGets or sets whether the component is enabled.
IsReadOnlyGets or sets whether the component is read-only.
TextGets or sets the text in the text area.
PlaceholderGets or sets the placeholder text.
ErrorGets or sets the error message.
MaxLengthGets or sets the maximum length of the text.
IsInvalidGets or sets whether the component is in an invalid state.
IsRequiredGets or sets whether the component is required.
IsDictatingTrue while the microphone button is listening.
IsEditable
CanDictate
Property
TextArea.TabIndex
public int TabIndex { set ; }

Gets or sets the tab index.

Property
TextArea.IsEnabled
public bool IsEnabled { get ; set ; }

Gets or sets whether the component is enabled.

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

Gets or sets whether the component is read-only.

Property
TextArea.Text
public string Text { get ; set ; }

Gets or sets the text in the text area.

Property
TextArea.Placeholder
public string Placeholder { get ; set ; }

Gets or sets the placeholder text.

Property
TextArea.Error
public string Error { get ; set ; }

Gets or sets the error message.

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

Gets or sets the maximum length of the text.

Property
TextArea.IsInvalid
public bool IsInvalid { get ; set ; }

Gets or sets whether the component is in an invalid state.

Property
TextArea.IsRequired
public bool IsRequired { get ; set ; }

Gets or sets whether the component is required.

Property
TextArea.IsDictating
public bool IsDictating

True while the microphone button is listening.

Property
TextArea.IsEditable
public bool IsEditable
Property
TextArea.CanDictate
public bool CanDictate

Methods

NameDescription
RenderRenders the component.
AttachAttaches a handler to the input updated event.
SetTextSets the text of the text area.
ClearTextClears the text.
SetPlaceholderSets the placeholder text.
DisabledSets whether the component is disabled.
ReadOnlySets the component as read-only.
NoSpellCheckDisables spell check.
RequiredSets the component as required.
WithDictationAdds 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.
DictationSourceSets 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).
StartDictationStarts 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.
StopDictationStops dictating; what was heard stays in the text area.
GetDictationThe dictation of this field, made on first use so a field that never dictates carries none.
FocusSets focus to the text area.
AsObservableReturns an observable of the text.
SetBoundValueProgrammatically updates the text area as part of a two-way binding (DOM input event is not raised).
AutoResizeEnables auto-resizing of the text area as the user types, based on the scrollHeight.
Method
TextArea.Render
public override HTMLElement Render()

Renders the component.

Returns

The rendered HTML element.

Method
TextArea.Attach
public void Attach(ComponentEventHandler<TextArea> handler)

Attaches a handler to the input updated event.

Parameters

handler
The handler.
Method
TextArea.SetText
public TextArea SetText(string text)

Sets the text of the text area.

Parameters

text
The text.

Returns

The current instance.

Method
TextArea.ClearText
public TextArea ClearText()

Clears the text.

Returns

The current instance.

Method
TextArea.SetPlaceholder
public TextArea SetPlaceholder(string placeholder)

Sets the placeholder text.

Parameters

placeholder
The placeholder text.

Returns

The current instance.

Method
TextArea.Disabled
public TextArea Disabled(bool value = true)

Sets whether the component is disabled.

Parameters

value
Whether it's disabled.

Returns

The current instance.

Method
TextArea.ReadOnly
public TextArea ReadOnly()

Sets the component as read-only.

Method
TextArea.NoSpellCheck
public TextArea NoSpellCheck()

Disables spell check.

Method
TextArea.Required
public TextArea Required()

Sets the component as required.

Method
TextArea.WithDictation
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.
Method
TextArea.DictationSource
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).

Method
TextArea.StartDictation
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.

Method
TextArea.StopDictation
public TextArea StopDictation()

Stops dictating; what was heard stays in the text area.

Method
TextArea.GetDictation
private DictationController GetDictation()

The dictation of this field, made on first use so a field that never dictates carries none.

Method
TextArea.Focus
public TextArea Focus()

Sets focus to the text area.

Method
TextArea.AsObservable
public IObservable<string> AsObservable()

Returns an observable of the text.

Method
TextArea.SetBoundValue
public void SetBoundValue(string value)

Programmatically updates the text area as part of a two-way binding (DOM input event is not raised).

Method
TextArea.AutoResize
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.

See also