Unified UI

Textarea

A multi-line text input with auto-resize, character count, and validation states.

Overview

The Textarea component is a production-ready multi-line text input. It supports 3 validation variants, 3 sizes, auto-resize, character counting, and all standard HTML textarea attributes.


Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add textarea
pnpm dlx @work-rjkashyap/unified-ui add textarea
npx @work-rjkashyap/unified-ui add textarea
bunx @work-rjkashyap/unified-ui add textarea

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import { Textarea } from "@work-rjkashyap/unified-ui";

Examples

Variants

Sizes

SizeFont SizePadding
sm12px8px
md14px12px
lg14px14px

Auto Resize

Character Count

0 / 200
0 / 100

States

Custom Rows

With Error Message

Bio must be at least 20 characters long.

With Success Message

Bio looks great!

Combined Features

0 / 500
0 / 300
Feedback must be at least 10 characters.

Props

PropTypeDefaultDescription
variant"default" | "error" | "success""default"Visual variant for validation state.
size"sm" | "md" | "lg""md"Size affecting font size and padding.
autoResizebooleanfalseWhether the textarea grows with content.
maxHeightnumberMaximum height in pixels when autoResize is enabled.
showCountbooleanfalseWhether to display a character counter.
maxLengthnumberMaximum character limit (enforced natively + shown in counter).
disabledbooleanfalseDisables the textarea.
readOnlybooleanfalseMakes the textarea read-only.
rowsnumberNumber of visible text lines (standard HTML attribute).
classNamestringAdditional CSS classes for the textarea element.

All standard <textarea> HTML attributes are also supported.


Accessibility

Always pair error/success variants with descriptive text linked via aria-describedby for screen reader users.

  • Error variant automatically sets aria-invalid="true" unless explicitly overridden.
  • Use aria-describedby to link the textarea to error/helper text elements.
  • Disabled textareas set both the disabled attribute and aria-disabled.
  • Focus ring is visible on keyboard navigation only (focus-visible).
  • The character counter is associated with the textarea for screen reader announcement.
  • Read-only textareas use a muted background to visually differentiate from editable state.

Design Tokens

The Textarea uses the following design system tokens:

TokenUsage
--borderDefault border color
--dangerError variant border
--successSuccess variant border
--muted-foregroundPlaceholder text color
--disabledDisabled background
--disabled-foregroundDisabled text color
--radius-mdBorder radius
--duration-fastTransition speed for focus/hover
--easing-standardEasing curve for transitions

On this page