Anchor Design System
Form

Textarea3.0

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

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-textarea';
  defineCustomElement();
</script>
<anchor-textarea label="This is a textarea"></anchor-textarea>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<anchor-textarea label="This is a textarea"></anchor-textarea>

Disabled

Webcomponent
<anchor-textarea label="This is a textarea" disabled></anchor-textarea>

Read Only

Webcomponent
<anchor-textarea label="This is a textarea" readonly></anchor-textarea>

Placeholder

Webcomponent
<anchor-textarea label="This is a textarea" placeholder="Placeholder"></anchor-textarea>

With Error Message

You add the error property to show an invalid textarea.

Webcomponent
<anchor-textarea label="This is a textarea" error="Error message"></anchor-textarea>

With Error Message as slot

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

Webcomponent
<anchor-textarea label="This is a textarea" error="Error message"></anchor-textarea>

Help text

Webcomponent
<anchor-textarea label="This is a textarea" help-text="Help message"></anchor-textarea>

Max length

Webcomponent
<anchor-textarea label="This is a textarea" maxlength="100""></anchor-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

anchor-textarea

Properties

PropertyAttributeDescriptionTypeDefault
ariaDescribedByaria-described-byaria-describedby attribute for the textarea fieldstringundefined
ariaLivearia-livearia-live attribute for the textarea fieldstringundefined
autocompleteautocompleteSet the autocomplete attribute for the textarea fieldstringundefined
autocorrectautocorrectThis prop decides if the textarea field should be autocorrect or notbooleanfalse
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.string`anchor-textarea-${uuidv4()}`
validityMissingValueTextvalidity-missing-value-textText to be displayed if when value is missing an native form validation is usedstringundefined
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<EventDetail>
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<EventDetail>
inputEventEvent emitted when the user is inputting something into the input fieldCustomEvent<EventDetail>

Methods

focusTextarea() => Promise<void>

Returns

Type: Promise<void>

CSS Custom Properties

NameDescription
--textarea-base-heightSet the base height of the textarea to 3 times the height of a standard component
--textarea-base-max-widthSet the base max width of the textarea
--textarea-base-widthSet the base width of the textarea
--textarea-border-base-widthSet the base width of the border
--textarea-border-colorSet the border color
--textarea-border-color-disabledSet the border color for a disabled textarea
--textarea-border-color-errorSet the border color for error states
--textarea-border-color-focusSet the border color on focus
--textarea-border-color-hoverSet the border color on hover
--textarea-border-radiusSet the border radius
--textarea-color-read-onlySet the border color for a readonly textarea
--textarea-line-heightSet the line height of the textarea
--textarea-outlineSet the color of the outline

Dependencies

Depends on

Graph


Built with StencilJS

On this page