The TextArea component provides a multi-line text input field with support for labels, helper text, and validation states.
Basic usage
import { TextArea } from '@raystack/apsara';
function App() {
return <TextArea label="Description" placeholder="Enter description" />;
}
Props
The label text displayed above the textarea.
Whether the textarea is required. When false, displays “(optional)” next to the label.
Tooltip text to display next to the label.
Helper text displayed below the textarea.
Whether the textarea is in an error state.
Whether the textarea is disabled.
width
string | number
default:"'100%'"
Width of the textarea container.
The controlled value of the textarea.
onChange
(event: React.ChangeEvent<HTMLTextAreaElement>) => void
Callback fired when the textarea value changes.
Placeholder text to display when the textarea is empty.
Additional CSS classes to apply to the textarea element.
Additional inline styles to apply to the textarea element.
With label and helper text
<TextArea
label="Comments"
helperText="Please provide detailed feedback"
placeholder="Type your comments here..."
/>
Required field
<TextArea
label="Description"
required
placeholder="This field is required"
/>
Optional field
<TextArea
label="Additional notes"
required={false}
placeholder="Optional field"
/>
With info tooltip
<TextArea
label="Bio"
infoTooltip="Tell us about yourself in a few sentences"
placeholder="Write your bio..."
/>
Error state
<TextArea
label="Message"
error
helperText="Message is required"
value=""
/>
Disabled state
<TextArea
label="Feedback"
value="This field is disabled"
disabled
/>
Controlled component
function ControlledTextArea() {
const [value, setValue] = useState('');
return (
<TextArea
label="Message"
value={value}
onChange={(e) => setValue(e.target.value)}
helperText={`${value.length} characters`}
/>
);
}
Custom width
<TextArea
label="Short note"
width="400px"
placeholder="Enter a short note"
/>
Custom rows
<TextArea
label="Description"
rows={10}
placeholder="Longer text area with more rows"
/>
Accessibility
- The TextArea component properly associates labels with the textarea element.
- Helper text and error messages are accessible to screen readers.
- The info tooltip icon supports keyboard navigation.
- The
required attribute is properly set for form validation.