Textarea
Textarea is a multi-line text field for free-form input such as comments, descriptions, or messages.
import { Textarea } from '@/components/ui/wideset/textarea/Textarea';
<div className="w-[20rem] max-w-full">
<Textarea
rows={3}
aria-label="Release notes"
placeholder="Tell the team what changed in this release…"
/>
</div>Installation
pnpm dlx wideset add textarea
Copies the component and any Wideset components it uses into your project.
Examples
Variants
Primary is the default. Danger marks text that failed validation, such as a required comment left empty or one over the length limit; put the reason in the FormField's errorText, which the field links to the textarea with aria-describedby, because the red border alone does not reach screen reader users.
import { Textarea } from '@/components/ui/wideset/textarea/Textarea';
export default function TextareaVariants() {
return (
<div className="gap-ws-12 flex w-[24rem] max-w-full flex-col">
<Textarea
variant="primary"
rows={3}
placeholder="Describe the issue"
aria-label="Description"
/>
<Textarea
variant="danger"
rows={3}
placeholder="Describe the issue"
aria-label="Description"
aria-invalid
/>
</div>
);
}Sizes
Medium is the default for forms. Small fits dense panels and inline comments, large a form where writing is the main task. Match the size of the other fields in the form; rows sets the starting height independently of the size.
import { Textarea } from '@/components/ui/wideset/textarea/Textarea';
export default function TextareaSizes() {
return (
<div className="gap-ws-12 flex w-[24rem] max-w-full flex-col">
{(['sm', 'md', 'lg'] as const).map((size) => (
<Textarea
key={size}
size={size}
rows={2}
placeholder="Add a comment"
aria-label="Comment"
/>
))}
</div>
);
}States
A disabled textarea cannot be focused and is skipped by the keyboard, so keep it only when the user can tell why. Text longer than rows scrolls inside the field, and the user can drag the corner to make it taller (resize="vertical" is the default).
import { Textarea } from '@/components/ui/wideset/textarea/Textarea';
export default function TextareaStates() {
return (
<div className="gap-ws-12 flex w-[24rem] max-w-full flex-col">
<Textarea rows={2} placeholder="Add a comment" aria-label="Comment" />
<Textarea rows={2} disabled placeholder="Add a comment" aria-label="Comment" />
<Textarea
rows={3}
aria-label="Release notes"
defaultValue={
'Invoices can now be exported as PDF.\nThe client list loads twice as fast.\nFixed: due dates showed in the wrong time zone.\nFixed: the search ignored archived projects.'
}
/>
</div>
);
}API reference
| Name | Description | Default |
|---|---|---|
contentClassName | Additional classes applied to the inner `<textarea>` element. `className` targets the outer wrapper. string | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | boolean | false |
resize | Directions in which the user can resize the field by dragging its corner. 'none''horizontal''vertical''both' | 'vertical' |
size | 'sm''md''lg' | 'md' |
variant | 'primary''danger' | 'primary' |
<textarea> is passed through to it. See MDN: <textarea>.Accessibility
- Name the field:
FormFieldwithhtmlFormatching the textareaid, oraria-label. dangersetsaria-invalid; screen reader users still need the reason, whichFormFieldlinks witharia-describedby.
import { Textarea } from '@/components/ui/wideset/textarea/Textarea';
<div className="w-[20rem] max-w-full">
<Textarea
rows={3}
aria-label="Release notes"
placeholder="Tell the team what changed in this release…"
/>
</div>