Skip to main content

Your opinion matters! Together with you, we want to continuously improve KoliBri. Share your ideas, wishes, or suggestions—quickly and easily.

Textarea

Synonyms: Multi-line input field, text area, text input field

A Textarea is a multi-line input field that allows users to enter longer texts with line breaks. Unlike single-line input fields, the textarea provides enough space for extensive text content such as descriptions, comments, or structured information. The component supports various configuration options such as resizing, character limits, accessibility, and automatic height adjustment.

Example

Standard textarea with label and placeholder text:

Message
<KolTextarea _hint="Additional hints for the input field" _label="Description" _placeholder="Please enter your description..." _rows={4} />

Accessibility

The Textarea component was developed with a focus on accessibility and supports various assistive technologies:

  • Label requirement: Every textarea must have a visible label via the _label attribute. This ensures that screen reader users understand the purpose of the input field.
  • Hint texts: With _hint, additional information can be provided that is accessible to all users and read aloud by screen readers.
  • Error messages: Invalid input can be provided with meaningful error messages via the _msg attribute, which are recognized and read aloud by assistive technologies.
  • Character counter: When the character counter is enabled (_has-counter), the status is updated with a 500ms delay to avoid interrupting screen readers with every keystroke. Additionally, a hidden text visible only to assistive technologies is displayed (e.g., "You can enter up to 100 characters").
  • Focus management: The textarea is fully operable via keyboard and provides clear focus indicators.
  • Required fields: Fields marked with _required are correctly communicated to assistive technologies.

Usage

Keyboard controls

The textarea supports the following keyboard shortcuts:

KeyFunction
TabFocuses the textarea or switches to the next interactive element.
Shift + TabSwitches to the previous interactive element.
Arrow keysNavigation within the text content of the focused textarea.
HomeJumps to the beginning of the current line.
EndJumps to the end of the current line.
Ctrl + ASelects all text in the textarea.
EnterInserts a line break (unlike single-line input fields).

Best Practices / Recommendations

  • Choose a sensible height: Start with a few rows (e.g., _rows="4") and allow resizing via _resize if needed, but avoid horizontal scrolling.
  • Sensible maximum length: Set a technically justified maximum character length and make it transparent with _has-counter and _max-length. For softer limits, use _max-length-behavior="soft".
  • Provide help texts: Provide format specifications or hints via the _hint attribute before input, not only after an error.
  • Leave control to the user: Do not force capitalization. Users retain control over the entered text.
  • Transparency with truncation: Never truncate or modify content without notice. Communicate clearly when truncation occurs.
  • Choose the right component: For short, single-line input, use the instead. Textareas are intended for multi-line content.
  • Meaningful labels: Use clear and precise labels that clearly communicate the purpose of the input field.
  • Error messages: For validation errors, provide specific, understandable hints via the _msg attribute.

Use cases

  • Comments and feedback: Capturing user comments, feedback, or reviews.
  • Descriptions: Entering product, article, or person descriptions.
  • Form fields: Capturing requests, inquiries, or justifications in forms.
  • Structured data: Entering multi-line addresses, notes, or instructions.
  • Messages: Composing emails, messages, or communications.
  • Documentation: Entering longer texts for documentation or content management systems.

Construction / Technology

Playground

Test the various properties of the Textarea component:

<KolTextarea _hint="Hint text" _label="Description" _placeholder="Please enter a description..." _rows={4} />

Functionalities

Simple Textarea

Standard textarea without special configuration:

<KolTextarea _label="Description" />

Automatic height adjustment

The textarea automatically adjusts its height to the content:

<KolTextarea _adjustHeight={true} _label="Description" _value="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat." />

Form attributes

Standard attributes for forms:

Message
<KolTextarea _label="Description" />

Available attributes:

  • _msg: Error messages or validation hints
  • _hint: Additional hints for the input
  • _disabled: Disables the input field (use with justification!)
  • _readOnly: Prevents editing of the field
  • _required: Marks required fields
  • _hideLabel: Visually hides the label (remains visible to assistive technologies)

Placeholder

The placeholder text is displayed when the input field is empty:

<KolTextarea _label="Description" _placeholder="Please enter a description..." />

Note: The placeholder should only serve as supplementary help and should not contain mandatory information, as the text disappears when typing.

Read-only mode

The textarea is read-only but not editable:

<KolTextarea _label="Description" _readOnly={true} />

Resize

The textarea can be resized using the _resize attribute:

<KolTextarea _label="Description" _resize="vertical" />

Available values:

  • vertical: Only vertically resizable (default)
  • horizontal: Only horizontally resizable
  • both: Resizable in both directions
  • none: No resizing possible

Number of rows

The initial height of the textarea can be specified in rows using the _rows attribute:

<KolTextarea _label="Description" _rows={6} />

Character limit and character counter

With the attributes _max-length, _max-length-behavior and _has-counter, the input length can be flexibly limited and at the same time provide visual feedback:

<KolTextarea _hasCounter={true} _label="Description" _maxLength={100} _rows={3} _value="Initial text" />
Attributes
AttributeTypeDefaultDescription
_has-counterbooleanfalseGlobal switch for the character counter. Only if this attribute is set (= true) will a counter be output.
_max-lengthnumberMaximum number of characters allowed. Effective only if _has-counter is active.
_max-length-behavior"hard" | "soft""hard"Specifies how the limit is handled if _max-length is set:
- hard: Additionally sets the native maxlength attribute and prevents further input.
- soft: Allows further input; the counter shows remaining or exceeded characters.
Output variants

| | _max-length | number | — | Maximum number of characters allowed. Effective only if _has-counter is active. | | _max-length-behavior | "hard" \| "soft" | "hard" | Specifies how the limit is handled if _max-length is set:
- hard: Additionally sets the native maxlength attribute and prevents further input.
- soft: Allows further input; the counter shows remaining or exceeded characters. |

Output variants
Case_has-counter_max-length_max-length-behaviorVisible text
1(empty) or false— (no counter)
2true(empty)n characters
3true100(empty) or hardn/100 characters
4true100soft50 characters still available
(or 5 characters too many)
— (no counter)

Note: If _max-length-behavior="soft" is used, the native maxlength attribute is not set – so the input field is not hard-limited.

Accessibility of the character counter
  • The counter updates with a delay of 500ms so that screen reader events are bundled and do not interrupt typing.
  • For screen readers, a hidden text visible only to assistive technologies is additionally displayed, such as: "You can enter up to 100 characters."
Summary
  • Without _has-counter there is never a counter.
  • With _has-counter and without _max-length only the currently entered number of characters is displayed.
  • With _has-counter and _max-length, _max-length-behavior determines whether the limit is implemented hard (hard) or softly (soft).

API

Overview

The Textarea component provides a larger input field for content. Unlike InputText, it also allows extensive content to be entered, including line breaks.

Properties

PropertyAttributeDescriptionTypeDefault
_accessKey_access-keyDefines the key combination that can be used to trigger or focus the component's interactive element.string | undefinedundefined
_adjustHeight_adjust-heightAdjusts the height of the element to its content.boolean | undefinedfalse
_disabled_disabledMakes the element not focusable and ignore all events.boolean | undefinedfalse
_hasCounter_has-counterShows a character counter for the input element.boolean | undefinedfalse
_hideLabel_hide-labelHides the caption by default and displays the caption text with a tooltip when the interactive element is focused or the mouse is over it.boolean | undefinedfalse
_hideMsg_hide-msgHides the error message but leaves it in the DOM for the input's aria-describedby.boolean | undefinedfalse
_hint_hintDefines the hint text.string | undefined''
_icons_iconsDefines the icon classnames (e.g. _icons="fa-solid fa-user").string | undefined | { right?: IconOrIconClass | undefined; left?: IconOrIconClass | undefined; }undefined
_label (required)_labelDefines the visible or semantic label of the component (e.g. aria-label, label, headline, caption, summary, etc.). Set to false to enable the expert slot.stringundefined
_maxLength_max-lengthDefines the maximum number of input characters.number | undefinedundefined
_maxLengthBehavior_max-length-behaviorDefines the behavior when maxLength is set. 'hard' sets the maxlength attribute, 'soft' shows a character counter without preventing input."hard" | "soft" | undefined'hard'
_msg_msgDefines the properties for a message rendered as Alert component.Omit<AlertProps, "_on" | "_variant" | "_hasCloser" | "_label" | "_level"> & { _description: string; } | string | undefinedundefined
_name_nameDefines the technical name of an input field.string | undefinedundefined
_on--Gibt die EventCallback-Funktionen für das Input-Event an.InputTypeOnBlur & InputTypeOnClick & InputTypeOnChange & InputTypeOnFocus & InputTypeOnInput & InputTypeOnKeyDown | undefinedundefined
_placeholder_placeholderDefines the placeholder for input field. To be shown when there's no value.string | undefinedundefined
_readOnly_read-onlyMakes the input element read only.boolean | undefinedfalse
_required_requiredMakes the input element required.boolean | undefinedfalse
_resize_resizeDefines whether and in which direction the size of the input can be changed by the user. (https://developer.mozilla.org/de/docs/Web/CSS/resize) In version 3 (v3), horizontal resizing is abolished. The corresponding property is then reduced to the properties vertical (default) and none."none" | "vertical" | undefined'vertical'
_rows_rowsMaximum number of visible rows of the element.number | undefinedundefined
_shortKey_short-keyAdds a visual shortcut hint after the label and instructs the screen reader to read the shortcut aloud.string | undefinedundefined
_spellCheck_spell-checkDefines whether the browser should check the spelling and grammar.boolean | undefinedundefined
_tooltipAlign_tooltip-alignDefines where to show the Tooltip preferably: top, right, bottom or left."bottom" | "left" | "right" | "top" | undefined'top'
_touched_touchedShows if the input was touched by a user.boolean | undefinedfalse
_value_valueDefines the value of the element.string | undefinedundefined

Methods

click

click() => Promise<void>

Clicks the primary interactive element inside this component.

Returns

Type: Promise<void>

focus() => Promise<void>

Sets focus on the internal element.

Returns

Type: Promise<void>

getValue() => Promise<string | undefined>

Returns the current value.

Returns

Type: Promise<string | undefined>

Slots

SlotDescription
The label of the input field.

Events

For the handling of events or callbacks, see .

EventTriggerValue
clickInput field is clicked-
focusInput field is focused-
blurInput field loses focus-
inputValue is changed by inputCurrent value of the input field
changeInput has been completedCurrent value of the input field