Skip to main content

fast-text-area

An implementation of an HTML textarea element as a form-connected web-component. The fast-text-area supports two visual appearances, outline and filled, with the control defaulting to the outline appearance.

Setup

import {
provideFASTDesignSystem,
fastTextArea
} from "@microsoft/fast-components";

provideFASTDesignSystem()
.register(
fastTextArea()
);

Usage

Live Editor
Result
Loading...

Create your own design

import {
TextArea,
textAreaTemplate as template,
} from "@microsoft/fast-foundation";
import { textAreaStyles as styles } from "./my-text-area.styles";

export const myTextArea = TextArea.compose({
baseName: "text-area",
template,
styles,
shadowOptions: {
delegatesFocus: true,
},
});
note

This component is built with the expectation that focus is delegated to the input element rendered into the shadow DOM.

API

Variables

NameDescriptionType
TextAreaResizeResize mode for a TextArea{ none: "none", both: "both", horizontal: "horizontal", vertical: "vertical", }

class: TextArea

Superclass

NameModulePackage
FormAssociatedTextArea/src/text-area/text-area.form-associated.js

Fields

NamePrivacyTypeDefaultDescriptionInherited From
readOnlypublicbooleanWhen true, the control will be immutable by user interaction. See readonly HTML attribute for more information.
resizepublicTextAreaResizeThe resize mode of the element.
autofocuspublicbooleanIndicates that this element should get focus after the page finishes loading.
formIdpublicstringThe id of the form the element is associated to
listpublicstringAllows associating a datalist to the element by https://developer.mozilla.org/en-US/docs/Web/API/Element/id.
maxlengthpublicnumberThe maximum number of characters a user can enter.
minlengthpublicnumberThe minimum number of characters a user can enter.
namepublicstringThe name of the element.
placeholderpublicstringSets the placeholder value of the element, generally used to provide a hint to the user.
colspublicnumber20Sizes the element horizontally by a number of character columns.
rowspublicnumberSizes the element vertically by a number of character rows.
spellcheckpublicbooleanSets if the element is eligible for spell checking but the UA.
proxyFormAssociatedTextArea
$presentationpublicComponentPresentation or nullA property which resolves the ComponentPresentation instance for the current component.FoundationElement
templatepublicElementViewTemplate or void or nullSets the template of the element instance. When undefined, the element will attempt to resolve the template from the associated presentation or custom element definition.FoundationElement
stylespublicElementStyles or void or nullSets the default styles for the element instance. When undefined, the element will attempt to resolve default styles from the associated presentation or custom element definition.FoundationElement

Methods

NamePrivacyDescriptionParametersReturnInherited From
selectpublicSelects all the text in the text areavoid
templateChangedprotectedvoidFoundationElement
stylesChangedprotectedvoidFoundationElement

Events

NameTypeDescriptionInherited From
changeEmits a custom 'change' event when the textarea emits a change event

Attributes

NameFieldInherited From
readOnly
resizeresize
autofocus
formformId
listlist
maxlength
minlength
namename
placeholderplaceholder
cols
rows
spellcheck

CSS Parts

NameDescription
labelThe label
rootThe element wrapping the control
controlThe textarea element

Slots

NameDescription
The default slot for the label

Additional resources