[ Forms ]
Textarea
A multi-line text field with the same label, helper text and error handling as Input. Users can resize it vertically.
3 examplesDark modeAccessible
Import#
import { Textarea } from 'reusify-ui';When to use#
- Free-form text longer than one line: comments, descriptions, messages, addresses.
- Set rows to roughly the length of the text you expect.
Examples#
Basic#
<Textarea label="Message" placeholder="Write your message…" rows={4} />Character counter#
Combine maxLength with helperText to show the remaining characters.
0/160 characters
function BioField() {
const [text, setText] = useState('');
const max = 160;
return (
<Textarea
label="Bio"
value={text}
maxLength={max}
onChange={(e) => setText(e.target.value)}
helperText={`${text.length}/${max} characters`}
/>
);
}Error#
Please write at least 20 characters
<Textarea label="Feedback" error="Please write at least 20 characters" defaultValue="Too short" />API reference#
<Textarea />
Also accepts every native <textarea> attribute and forwards its ref.
| Prop | Type | Default | Description |
|---|---|---|---|
rows | number | 4 | Visible number of text lines. |
label | ReactNode | - | Label rendered above the control and linked to it via htmlFor. |
helperText | ReactNode | - | Hint shown below the control. |
error | boolean | string | - | Marks the field invalid (red border, aria-invalid). A string also replaces the helper text. |
fullWidth | boolean | false | Makes the field fill its container. |
containerClassName | string | - | Class for the outer wrapper. className goes on the native element. |
required | boolean | false | Native required, plus a red asterisk after the label. |
disabled | boolean | false | Disables and dims the field. |
rows4numberVisible number of text lines.
label-ReactNodeLabel rendered above the control and linked to it via htmlFor.
helperText-ReactNodeHint shown below the control.
error-boolean | stringMarks the field invalid (red border, aria-invalid). A string also replaces the helper text.
fullWidthfalsebooleanMakes the field fill its container.
containerClassName-stringClass for the outer wrapper. className goes on the native element.
requiredfalsebooleanNative required, plus a red asterisk after the label.
disabledfalsebooleanDisables and dims the field.
Accessibility#
- Uses the same label / aria-describedby / aria-invalid wiring as Input.
- The native resize handle stays available for users who need more room.