Textarea

Inputs

Stablev1.0.0

Multi-line text input component with auto-resize support and validation states

Preview

Installation

npx @component-labs/cli add textarea

This will:
- Install required dependencies
- Copy the Textarea component to your project
- Add utility functions (cn helper)

Make sure you've initialized Component Labs first:
```bash
npx @component-labs/cli init
```

Usage

import { Textarea } from "@component-labs/ui";

<Textarea placeholder="Enter your message..." />

Props

NameTypeDefaultDescription
variant"default" | "error""default"Visual style variant
resize"none" | "vertical" | "horizontal" | "both""vertical"Resize behavior (disabled when autoResize is true)
errorstring-Error message to display
autoResizebooleanfalseWhether the textarea should automatically resize based on content
minRowsnumber3Minimum number of rows when autoResize is enabled
maxRowsnumber-Maximum number of rows when autoResize is enabled
rowsnumber3Number of visible rows (when autoResize is disabled)
disabledboolean-Whether the textarea is disabled
placeholderstring-Placeholder text
classNamestring-Additional CSS classes

Examples

Basic

A simple textarea

<Textarea placeholder="Enter your message..." />

With Error

Textarea with error state

<Textarea
  error="This field is required"
  placeholder="Required field"
/>

Auto Resize

Textarea that grows with content

<Textarea
  autoResize
  minRows={3}
  maxRows={10}
  placeholder="Type to see auto-resize..."
/>

Disabled

Disabled textarea

<Textarea disabled placeholder="Cannot edit" />

No Resize

Textarea with resize disabled

<Textarea resize="none" rows={5} />

Performance

Bundle Size

~2KB gzipped

Minified and gzipped

Dependencies

  • class-variance-authority
  • clsx
  • tailwind-merge

Accessibility

  • Proper ARIA attributes for error states
  • Keyboard navigation support
  • Focus management
  • Screen reader friendly error messages