Skip to content

Textarea

The Textarea component is a multi-line text input with options for a label, caption, character counter, resizing behaviour, validation states, and an info tooltip.

Variations

Disabled

Resizable

Auto resize

The Textarea component supports automatic height adjustment based on content with the autoResize prop. When enabled, the textarea grows and shrinks to fit its content, eliminating the need for manual scrolling.

autoResize uses the native CSS field-sizing: content when the browser supports it, and respects a maximum height limit to prevent excessive growth. It may not work as expected in Firefox, which does not yet support field-sizing: content.

Theme

Textarea derives its visual state from error and warning: passing an error message applies the danger theme, and passing a warning message applies the warning theme. You can also set theme directly (warning) to colour the field without a message.

Character limit

The Textarea component supports a maxCharacters prop, which shows a live used / max counter beside the label. The counter is informational — it does not block typing past the limit.

Sizes

The Textarea component supports the sizes sm and md. The default size is md.

With tooltip

tooltipContent sets the content of the label’s info tooltip. tooltipProps passes additional props to the tooltip.

Orientation

The Textarea component accepts an optional orientation prop, which defines the layout direction of the textarea and its label. Available options are horizontal and vertical (default).

Installation

import { Textarea } from "@harnessio/ui/components";
<Textarea
label="Textarea label"
placeholder="Placeholder"
name="textarea-name"
onChange={handleChange}
/>;