Textarea
A versatile textarea component with multiple variants, sizes, resize options, and dark mode support
Installation
Install the Textarea component using the nocta-ui CLI:
npx nocta-ui add textarea
Then import the component:
import { Textarea } from '@/components/ui/textarea';
Basic Usage
Default Textarea
Textarea with Label
Textarea with Helper Text
Provide a detailed description of your project goals and requirements
Variants
The Textarea component supports three variants: default
, error
, and success
.
Description is required
Description looks good!
Sizes
Three size options are available: sm
, md
, and lg
. The default size is md
.
Resize Options
Control how the textarea can be resized with the resize
prop.
Resize is disabled
Can be resized vertically
Can be resized horizontally
Can be resized in both directions
Row Configuration
Adjust the initial height of the textarea using the rows
prop.
Textarea States
Disabled State
This field is disabled
Read-only State
This field is read-only
Character Limit
Maximum 250 characters allowed
Customization
Custom Container
Custom container styling applied
API Reference
Props
Prop | Type | Default | Description |
---|---|---|---|
variant | 'default' | 'error' | 'success' | 'default' | Visual variant of the textarea |
size | 'sm' | 'md' | 'lg' | 'md' | Size of the textarea |
label | string | undefined | Label text displayed above the textarea |
helperText | string | undefined | Helper text displayed below the textarea |
errorMessage | string | undefined | Error message (shown when variant is 'error') |
resize | 'none' | 'vertical' | 'horizontal' | 'both' | 'vertical' | Resize behavior of the textarea |
rows | number | 4 | Initial number of visible text lines |
className | string | '' | Additional CSS classes for the textarea element |
containerClassName | string | '' | Additional CSS classes for the container |
All standard HTML textarea attributes are also supported through props spreading.
Accessibility
- Proper label association using
htmlFor
andid
attributes - Support for
aria-describedby
when helper text is present - Focus management with visible focus indicators
- Screen reader compatible error states
- Keyboard navigation support