Skip to main content

Textarea

Several lines of text with a label, help and error.

<mm-textarea name="description" label="Description" rows="4" maxlength="500" autosize
help="Shown at the top of the asset page."></mm-textarea>

Guidance​

Textareas take several lines: descriptions, documentation notes, review comments. autosize grows the field with its content instead of scrolling, maxlength adds a character counter, and mono sets the text in mono for machine strings such as a list of MRNs or a JSON payload.

Form-associated: submits value under name, validates required, minlength and maxlength, resets with the form and is disabled by a disabled fieldset.

Properties​

PropertyAttributeTypeDefaultDescription
valuevaluestring''The current value. The value attribute is the default the form resets to.
placeholderplaceholderstring''
rowsrowsnumber3Visible rows; the minimum height when autosize is set.
autosizeautosizebooleanfalseGrows with the content instead of scrolling.
minlengthminlengthnumber | undefined
maxlengthmaxlengthnumber | undefinedMaximum length; also shows a counter.
readonlyreadonlybooleanfalse
monomonobooleanfalseSets the text in mono, for machine strings.
labellabelstring''Field label. Rendered above the control unless hide-label, and always the accessible name.
helphelpstring''Help text under the control.
errorerrorstring''Error text: a sentence saying what to fix. Shows the crimson border, an icon and sets aria-invalid.
hideLabelhide-labelbooleanfalseHides the label visually; it stays the accessible name.
optionaloptionalbooleanfalseMarks the field as optional, in words.
namenamestring''Name submitted with the form.
disableddisabledbooleanfalseDisables the control and excludes it from submission.
requiredrequiredbooleanfalseRequires a value before the form submits.
formHTMLFormElement | null
validityValidityState
validationMessagestring
willValidateboolean
isDisabledbooleanTrue when disabled directly or by a disabled ancestor fieldset.

Methods​

MethodDescription
formResetCallback()Restore the initial value when the owning form resets.

Events​

EventDetailDescription
mm-inputCustomEvent<MmValueDetail>On every edit.
mm-changeCustomEvent<MmValueDetail>When the value is committed (blur after editing).
inputInputEventNative, composed; on every edit.
changeEventNative, re-dispatched on the host when the value is committed.

CSS parts​

PartDescription
labelThe label.
controlThe bordered box.
textareaThe native textarea.
helpThe help line.
errorThe error line.
counterThe character counter.

Examples​

Every state of mm-textarea in Storybook, with keyboard and screen reader tests.