Anchor Design System

Textarea

Textarea component is a multi-line Input which allows you to write large texts.

Installation

Usage

Disabled

Read Only

Placeholder

With Error Message

You add the error property to show an invalid textarea.

With Error Message as slot

You add the error-msg slot to show an invalid textarea.

Help text

Max length

Slots

  • error-msg: The error message of the textarea.

Accessibility

  • Built with a native <textarea> element.
  • Visual and ARIA labeling support.
  • Change, clipboard, composition, selection, and input event support.
  • Required and invalid states exposed to assistive technology via ARIA.
  • Support for description and error message help text linked to the input via ARIA.

API

Properties

PropertyAttributeDescriptionTypeDefault
ariaDescribedByaria-described-byaria-describedby attribute for the textarea fieldstringundefined
ariaLivearia-livearia-live attribute for the textarea fieldstringundefined
autocorrectautocorrectThis prop decides if the textarea field should be autocorrected or not"off" | "on"'off'
autofocusautofocusThis prop decides if the textarea field should be autofocused or notbooleanfalse
disableddisabledThis prop decides if the textarea field should be disabled or notbooleanfalse
errorerrorShow an error messagestring''
helpTexthelp-textShow a help textstringundefined
labellabelThe label text of the textarea fieldstringundefined
maxlengthmaxlengthThe maximum length of the textarea fieldnumberundefined
messagePlacementmessage-placementThis prop decides if the messages should render between the label of an textarea and the textarea field, or below the textarea field."below" | "inside"'inside'
namenameThe name of the textarea fieldstringundefined
noResizeno-resizeThis prop decides if the textarea field should be resizable or notbooleanfalse
placeholderplaceholderThe placeholder text of the textarea fieldstringundefined
readonlyreadonlyThis prop decides if the textarea field should be readonly or notbooleanfalse
requiredrequiredThis prop decides if the textarea field is required or notbooleanfalse
selectOnFocusselect-on-focusThis prop decides if all content inside the textarea should be selected when it gets focusbooleanundefined
spellCheckspell-checkThis prop decides if the textarea field should be spellchecked or not"false" | "true"'false'
uuiduuidA unique identifier for the textarea component.stringanchor-textarea-${uuidv4()}
valuevalueThe value in the textarea field. Use this to set a value and read itstring''

Events

EventDescriptionType
blureventEvent emitted when the user blurs the textarea fieldCustomEvent<any>
cleareventEvent emitted when the user clears the textarea fieldCustomEvent<any>
focuseventEvent emitted when the user is focusing the textarea fieldCustomEvent<any>
inputChangeEvent emitted when the textarea value is changed. Only triggers when focus leaves the textarea elementCustomEvent<any>
inputEventEvent emitted when the user is inputting something into the input fieldCustomEvent<any>

Methods

focusTextarea() => Promise<void>

Returns

Type: Promise<void>

Dependencies

Depends on

Graph

graph TD;
  anchor-textarea --> anchor-label
  anchor-textarea --> anchor-icon
  style anchor-textarea fill:#f9f,stroke:#333,stroke-width:4px

On this page