The TextArea component provides a multi-line text input field for longer text content. It's designed for forms, comments, descriptions, and any interface where users need to input multiple lines of text.
import { TextArea } from '@dashflowx/core'export default function TextAreaExample() {return (<TextAreaplaceholder="Enter your message..."rows={4}/>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes |
placeholder | string | 'Enter your message...' | Placeholder text |
rows | number | 4 | Number of visible text lines |
disabled | boolean | false | Whether the textarea is disabled |
fullwidth | boolean | true | Whether the textarea takes full width |
lable | string | 'Message' | Label for the textarea |
required | boolean | false | Whether the field is required |
prefixElement | JSX.Element | - | Element to display before the textarea |
sufixElement | JSX.Element | - | Element to display after the textarea |
sucessMsg | string | - | Success message to display |
errorMsg | string | - | Error message to display |
import { TextArea } from '@dashflowx/core'export default function BasicTextArea() {return (<TextAreaplaceholder="Enter your message..."rows={4}/>)}
Preview:
import { TextArea } from '@dashflowx/core'export default function CustomStyledTextArea() {return (<TextAreaplaceholder="Enter your message..."rows={4}className="border border-blue-500 rounded-lg p-4"/>)}
Preview:
import { TextArea } from '@dashflowx/core'export default function TextAreaWithLabel() {return (<TextArealable="Comments"placeholder="Enter your comments..."rows={4}/>)}
Preview:
import { TextArea } from '@dashflowx/core'export default function RequiredTextArea() {return (<TextArealable="Description"placeholder="Enter description..."rows={4}required={true}/>)}
Preview:
import { TextArea } from '@dashflowx/core'export default function DisabledTextArea() {return (<TextArealable="Read Only"placeholder="This field is disabled..."rows={4}disabled={true}/>)}
Preview:
import { TextArea } from '@dashflowx/core'export default function LargeTextArea() {return (<TextArealable="Long Text"placeholder="Enter a long message..."rows={8}/>)}
Preview:
const contactForm = (<TextArealable="Message"placeholder="Enter your message..."rows={4}required={true}/>);
const commentSection = (<TextArealable="Add Comment"placeholder="Write your comment..."rows={3}/>);
const descriptionField = (<TextArealable="Description"placeholder="Enter description..."rows={5}/>);
const feedbackForm = (<TextArealable="Feedback"placeholder="Share your feedback..."rows={6}/>);
Use clear and descriptive labels for textareas.
// ✅ Good - Clear labels<TextArea lable="Project Description" />// ❌ Avoid - Unclear labels<TextArea lable="Text" />
Set appropriate number of rows based on expected content length.
// ✅ Good - Appropriate rows<TextArea rows={4} /> // For comments<TextArea rows={8} /> // For descriptions// ❌ Avoid - Too few or too many rows<TextArea rows={1} /> // For long content<TextArea rows={20} /> // For short content
Use helpful placeholder text to guide users.
// ✅ Good - Helpful placeholders<TextArea placeholder="Describe your project requirements..." />// ❌ Avoid - Unhelpful placeholders<TextArea placeholder="Enter text..." />
Clearly indicate required fields.
// ✅ Good - Required indicator<TextArea lable="Description" required={true} />// ❌ Avoid - No required indicator<TextArea lable="Description" />
Maintain consistent styling across textareas.
// ✅ Good - Consistent styling<TextArea className="standard-textarea-style" />// ❌ Avoid - Inconsistent styling<TextArea className="random-styles" />
You can customize the textarea appearance using CSS classes:
<TextAreaclassName="border border-gray-300 rounded-lg p-4"rows={4}/>
Use different themes for different contexts:
// Light theme<TextArea className="bg-white border-gray-200" />// Dark theme<TextArea className="bg-gray-900 border-gray-700 text-white" />// Brand theme<TextArea className="bg-blue-50 border-blue-200" />
Use different sizes for different emphasis levels:
// Small textarea<TextArea rows={2} className="text-sm" />// Standard textarea<TextArea rows={4} className="text-base" />// Large textarea<TextArea rows={8} className="text-lg" />
Load textarea content dynamically:
const [textareaContent, setTextareaContent] = useState('');useEffect(() => {// Load content from APIloadTextareaContent().then(setTextareaContent);}, []);
Add character count functionality:
const [characterCount, setCharacterCount] = useState(0);<TextAreaonChange={(e) => setCharacterCount(e.target.value.length)}maxLength={500}/><div>Characters: {characterCount}/500</div>
Implement auto-resizing textarea:
const autoResizeTextarea = (textarea) => {textarea.style.height = 'auto';textarea.style.height = textarea.scrollHeight + 'px';};<TextAreaonInput={(e) => autoResizeTextarea(e.target)}rows={1}/>
- Input: For single-line text input
- Form: For form containers
- Label: For form labels
- Button: For form actions
- Card: For form containers
For the complete API reference and advanced usage patterns, see the TextArea API documentation.
