Textarea
Forms
Input
Multi-line text input for longer form content like descriptions, messages, and comments.
Preview
Simple multi-line text input
Sizes
Three height options: sm, md, and lg
Small (60px min height)
Medium (80px min height)
Large (120px min height)
With Character Count
Show character count with max length
0 / 200 characters
Error State
Textarea with validation error
Description is required and must be at least 10 characters
Disabled State
Disabled textarea
Feedback Form Example
Complete form with textarea
Be as detailed as possible to help us improve
Props
Textarea component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'error' | 'default' | Visual variant |
size | 'sm' | 'md' | 'lg' | 'md' | Minimum height |
placeholder | string | — | Placeholder text |
rows | number | — | Number of visible rows |
maxLength | number | — | Maximum character count |
disabled | boolean | false | Disable the textarea |
className | string | — | Additional CSS classes |
Usage
Import and implementation example
import { Textarea } from '@/components/ui/textarea'
import { Label } from '@/components/ui/label'
export default function Example() {
const [value, setValue] = useState('')
return (
<>
{/* Basic textarea */}
<div className="space-y-2">
<Label htmlFor="message">Message</Label>
<Textarea
id="message"
placeholder="Type your message here..."
/>
</div>
{/* With character limit */}
<Textarea
value={value}
onChange={(e) => setValue(e.target.value)}
maxLength={500}
placeholder="Max 500 characters..."
/>
{/* Different sizes */}
<Textarea size="sm" placeholder="Small" />
<Textarea size="md" placeholder="Medium" />
<Textarea size="lg" placeholder="Large" />
{/* Error state */}
<Textarea variant="error" placeholder="Has error..." />
</>
)
}Features
Built-in functionality
- Resizable: Vertical resize enabled by default
- Three sizes: Small (60px), medium (80px), large (120px)
- Error state: Visual feedback for validation errors
- Focus ring: Clear focus indicator
- Smooth transitions: 200ms color transitions
- Max length: Optional character limit
- Custom rows: Set visible rows directly
- Dark mode: Full dark mode support
Accessibility
Accessibility considerations
ARIA Attributes
Uses native textarea elementProperly labeled via htmlForSupports aria-describedby for errorsKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Focus the textarea |
| Type | Enter text content |
| Shift+Tab | Move to previous element |
Notes
- Always use with Label for accessibility
- Error messages should use aria-describedby
- Placeholder is not a substitute for label
- Resize handle is keyboard accessible