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 textareapnpm dlx @work-rjkashyap/unified-ui add textareanpx @work-rjkashyap/unified-ui add textareabunx @work-rjkashyap/unified-ui add textareaIf 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-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import { Textarea } from "@work-rjkashyap/unified-ui";Examples
Variants
Sizes
| Size | Font Size | Padding |
|---|---|---|
sm | 12px | 8px |
md | 14px | 12px |
lg | 14px | 14px |
Auto Resize
Character Count
States
Custom Rows
With Error Message
With Success Message
Combined Features
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "error" | "success" | "default" | Visual variant for validation state. |
size | "sm" | "md" | "lg" | "md" | Size affecting font size and padding. |
autoResize | boolean | false | Whether the textarea grows with content. |
maxHeight | number | — | Maximum height in pixels when autoResize is enabled. |
showCount | boolean | false | Whether to display a character counter. |
maxLength | number | — | Maximum character limit (enforced natively + shown in counter). |
disabled | boolean | false | Disables the textarea. |
readOnly | boolean | false | Makes the textarea read-only. |
rows | number | — | Number of visible text lines (standard HTML attribute). |
className | string | — | Additional 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-describedbyto link the textarea to error/helper text elements. - Disabled textareas set both the
disabledattribute andaria-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:
| Token | Usage |
|---|---|
--border | Default border color |
--danger | Error variant border |
--success | Success variant border |
--muted-foreground | Placeholder text color |
--disabled | Disabled background |
--disabled-foreground | Disabled text color |
--radius-md | Border radius |
--duration-fast | Transition speed for focus/hover |
--easing-standard | Easing curve for transitions |